• Resolved psuba

    (@psuba)


    I am getting a strange behaviour. On a number of pages where I am displaying the user’s avatar, it works OK as long as I am viewing those pages as a logged in user (as administrator). As soon as I log off, a number of those avatar images revert to displaying the default avatar, and there are a number of notice messages if I am switching on WP_DEBUG. Those notices are all coming from within a core wp_include file, from within the get_comment() function (trying to get property of a non-object).

    I traced it back as definitely a behaviour linked to this plugin – as soon as I deactivate it, the notices are gone and the site functions as expected with the proper images displayed.

    Some further info that may be relevant – I am also using Avatar Manager to enable users to upload avatar images directly, and also using W3 Total Cache, so the issue might be related to plugin conflict.

    Hope you can assist and if this is related to the plugin, fix it?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Harry Milatz

    (@harry-milatz)

    Hi,

    yes, when you are logged in as administrator my plugin won’t serve the cached images.

    can you post here the notice messages from the debugging here?

    And a link (or some more;) ) where i can see the issue would be helpful, just to have a look. You can post it here or mail me to harry[aet]all4hardware4u[dot]de

    Is this the other plugin:
    https://de.www.ads-software.com/plugins/avatar-manager/

    Best regards,
    Harry

    Thread Starter psuba

    (@psuba)

    Hi,

    For each user avatar I am trying to display I am getting this sequence of errors:
    Notice: Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 97
    Notice: Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 97
    Notice: Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 28
    Notice: Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 46

    As you can see they are all within the get_comment() function definition, trying to use properties of a base class which is obviously not set but get_comments assumes it is.

    Note that when I am activating the plugin, I am also now getting the message:
    The plugin generated 700 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    This is what was captured in the debug.log whilst activating:
    [14-Jan-2017 11:24:02 UTC] PHP Notice: Undefined offset: 1 in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 212
    [14-Jan-2017 11:24:02 UTC] PHP Notice: Undefined offset: 1 in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 212
    [14-Jan-2017 11:24:02 UTC] PHP Notice: Undefined offset: 1 in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 212
    [14-Jan-2017 11:24:02 UTC] PHP Notice: Undefined variable: avatar_size in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 220

    Yes, the plugin you included the link to is the one I am using. Also, I have followed the instructions described on that plugin’s page to add and set a new custom default avatar for complete disclosure.

    In terms of you having a look – we are working now on adding content from an old site getting ready to launch with several people working on it so I hope you can resolve it without having to activate your plugin and triggering these errors. I doubt you would see much because the way I coded the page, the only thing you see is that all these users avatars are replaced by the custom default avatar – that is a fallback position, so other than the error messages I copied above I doubt this would be of any use. If you insist, let me know and we can try over Email to set a time period where I let our editor community know to expect these issues, and enable your plugin for you to be able to look at it and troubleshoot.

    Plugin Author Harry Milatz

    (@harry-milatz)

    Hi again,

    is my plugin working if you are not using the Avatar Manager?
    I think it is the removing filter in the Avatar Manager plugin:

    	if ( $user_has_custom_avatar ) {
    		// Removes the function attached to the specified action hook.
    		remove_filter( 'get_avatar', 'avatar_manager_get_avatar' );
    	}

    My plugin uses of course this core function from WordPress.
    I will try to solve this.

    Best regards,
    Harry

    Plugin Author Harry Milatz

    (@harry-milatz)

    Hi,

    please update to version 1.5.1 and give me a report. This should solve the issue.

    I did not get this message on my tests:
    Notice: Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 97

    So maybe it is not a notice with my plugin or the Avatar Manager.

    Best regards,
    Harry

    Thread Starter psuba

    (@psuba)

    Hi Harry,

    thanks for keeping with it.
    Unfortunately, this seems to be a partial fix.

    The good news is that it seems like the correct avatars are now returned.

    However, I am still getting a lot of error notices and warnings:

    When activating the updated plugin, I am in fact getting slightly MORE errors:

    [16-Jan-2017 11:41:39 UTC] PHP Notice:  Undefined offset: 1 in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 212
    [16-Jan-2017 11:41:39 UTC] PHP Notice:  Undefined offset: 1 in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 212
    [16-Jan-2017 11:41:39 UTC] PHP Notice:  Undefined offset: 1 in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 212
    [16-Jan-2017 11:41:39 UTC] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 220
    [16-Jan-2017 11:41:39 UTC] PHP Notice:  Undefined variable: avatar_size in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 222

    Also, whilst you may not be seeing the error notices I quoted before for the avatar displays, they are still there for me.

    They are all triggered when I execute the following line in my code:
    $avatar = get_avatar($userID,400);

    I have confirmed this by triggering an error log before and after this line to make sure, and now this is the debug log for each user where I am calling the above line:

    [16-Jan-2017 11:42:46 UTC] Attempting to get Avatar for user ID 5
    [16-Jan-2017 11:42:47 UTC] PHP Notice:  Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 97
    [16-Jan-2017 11:42:47 UTC] PHP Notice:  Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 97
    [16-Jan-2017 11:42:47 UTC] PHP Notice:  Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 28
    [16-Jan-2017 11:42:47 UTC] PHP Notice:  Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 46
    [16-Jan-2017 11:42:47 UTC] Avatar call complete

    Of course, the first and last lines are my logs enclosing the get_avatar call.
    These are all gone as soon as I disable your plugin.

    Plugin Author Harry Milatz

    (@harry-milatz)

    Hi again,

    can you give me the the filenames and path were in your theme is the size for your avatars is set? My plugin try to get the size from those files and i think i should/coukd expand the list in my plugin.
    The plugin search for “avatar_size” and “get_avatar” in some files of the theme:

    	$dateinamen[]=get_template_directory().'/functions.php';
    	$dateinamen[]=get_template_directory().'/single.php';
    	$dateinamen[]=get_template_directory().'/comments.php';
    	$dateinamen[]=get_template_directory().'/includes/functions/comments.php';

    The notices tells us that there is no file in the array and the size is get to the fallback “67”.

    I will expand this list if you can give me another file(s). I think that the file from your template is not in there and this causes the notices.

    After this we can see if the notices from “wp-includes/comment-template.php” could be caused by another plugin or by mine.

    Best regards,
    Harry

    Thread Starter psuba

    (@psuba)

    Sorry I am not sure I understand what you are asking. Are you asking in which files I am calling get_avatar?

    Peter

    Plugin Author Harry Milatz

    (@harry-milatz)

    Hi Peter,

    yes:) If there are some other files in yor theme which are calling “avatar_size” and/or “get_avatar” i could add them to my plugin. But if there are no other files i am working on another solution/fallback anyway.

    I am just working on the new version to get away the “PHP Notice: Trying to get property of non-object in /[basedir]/public_html/wp-includes/comment-template.php on line 97” notice. I was able to reproduce the notice and figure it out. On my site it was shown when on a post or page are no comments.

    Thread Starter psuba

    (@psuba)

    Hi Harry,

    I also call get_avatar in /include/meta.php which I guess you could rely on as a “usual suspect”.

    However, I am also calling it in some specific template that I have made for a custom post type. Here is the call displaying a size 400px (quite large) avatar, and nowhere else. So I am not sure you can rely on these calls to be in specific files in all cases… so I am hoping you can solve this without trying to second guess the programmers of other plugins/themes/customisations!

    Peter

    Plugin Author Harry Milatz

    (@harry-milatz)

    Hi Peter,

    i will add the meta.php, i think it could be a supect too;)

    The call with a size about 400px is too large to be in my call to get the usual avatar size.

    I think in one hour the new version should be online.

    Best regards,
    Harry

    Thread Starter psuba

    (@psuba)

    Hi Harry,

    Thanks – I think it is getting there. I no longer get all of those error messages, and things seem to display OK on the site.

    There are still some notices though which you may be interested:
    – I still got a warning when activating the new version of the plugin that it generated unexpected output
    – I have a PHP notice in the debug log as follows (I suspect this was the unexpected output because I could not immediately see notices on the displayed pages):
    PHP Notice: Undefined variable: avatar_size in /[basedir]/public_html/wp-content/plugins/harrys-gravatar-cache/harrys-gravatar-cache.php on line 238

    Plugin Author Harry Milatz

    (@harry-milatz)

    Hi Peter,

    thanks for reporting me.

    The version 1.5.3 should “kill” the last PHP Notice;)

    I could not figure out the “unexpected output” on my tests now. Let me know if it is still there.

    Best regards,
    Harry

    Thread Starter psuba

    (@psuba)

    Hi Harry,

    After upgrading to 1.53, I no longer get unexpected output message, nor the PHP notice. So I think you have fixed these issues now.

    Thanks for the good work!

    Note that I noticed there are no version notes for the last few versions of the plugin when I am looking at the WordPress admin panel (only up to an earlier version), so you may want to add these for others.

    Peter

    Plugin Author Harry Milatz

    (@harry-milatz)

    Hi Peter,

    thanks for reporting that to me:)
    Feel free to recommend my plugin;)

    Ok i see this, i will take a look to let show the changelog complete. In the readme.txt it is all there.

    Best regards,
    Harry

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Warnings and avatar display issues when not logged in’ is closed to new replies.