• Resolved xoogu

    (@xoogu)


    Getting this notice in my debug log:
    PHP Notice: Trying to get property of non-object in class.akismet.php on line 121

    For the moment I’m just changing that line from
    $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
    to:
    $comment[ 'comment_post_modified_gmt' ] = is_object($post) ? $post->post_modified_gmt : null;

    https://wordpress.org/plugins/akismet/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Christopher Finke

    (@cfinke)

    $post should always be an object at that point. What other plugins are you running? It’s possible one of them is incompatible with Akismet.

    Plugin Contributor Greg

    (@jgs)

    @xoogo, still having trouble with this?

    Thread Starter xoogu

    (@xoogu)

    Yes, I’m seeing the following in the debug log:
    PHP Notice: Trying to get property of non-object in wp-content/plugins/akismet/class.akismet.php on line 129

    I have 11 entries in the debug log, all with this error, from 11th June up to 7th July. So it is obviously some specific set of circumstances that don’t occur very often that cause the error.

    I’ll see if I can set something up to provide some debug info (at the moment I’m filtering akismet_debug_log, so don’t have any debug info).

    After line 128 I’ll add:

    if ( !is_object($post) && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
    			error_log( print_r( compact( 'comment' ), true ) );
    		}

    Oops, just realised the errors were on a site with Akismet 3.12. Well, I’ll make the debug changes to 3.13 and see how it goes.

    Plugin Author Christopher Finke

    (@cfinke)

    It’s probably worthwhile to also log the value of $post, in case it’s not just false or null.

    Thread Starter xoogu

    (@xoogu)

    I’ve got quite a lot of debug entries in my debug.log now. Here’s an example: http://pastebin.com/u9GGtgAZ

    As you can see, $post is empty (because comment_post_ID is 0).

    Unfortunately as this is a live site I can’t really disable all other plugins / switch to a default theme to check if the problem is a conflict somewhere.

    Plugin Author Christopher Finke

    (@cfinke)

    Those comment objects should have some value for comment_post_ID, so my guess would have to remain that another plugin is somehow modifying $comment, resetting comment_post_ID (and probably not intentionally).

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘PHP Notice’ is closed to new replies.