PHP Notices in error.log

  • Josh

    #7994

    Hi Syahir!

    Okay… I noticed some of my error logs were getting enormously huge, so I began “digging”. Quite a few were caused because I upgraded my server PHP from 5.2 to 5.3.. and forgot to update the PHP modules accordingly. This has now be fixed.

    Now, here is my question. I still get a few recurring notices in the error log. It is a “block” of notices, as follows:

    [23-Aug-2013 03:11:42 America/Kentucky/Louisville] PHP Notice:  Undefined variable: tax in /home/XXXX/public_html/wp-content/themes/graphene/includes/theme-loop.php on line 542
    [23-Aug-2013 03:12:48 America/Kentucky/Louisville] PHP Notice: Trying to get property of non-object in /home/XXXX/public_html/wp-includes/comment-template.php on line 776
    [23-Aug-2013 03:12:48 America/Kentucky/Louisville] PHP Notice: Trying to get property of non-object in /home/XXXX/public_html/wp-content/themes/graphene/includes/theme-comments.php on line 206
    [23-Aug-2013 03:12:48 America/Kentucky/Louisville] PHP Notice: Trying to get property of non-object in /home/XXXX/public_html/wp-includes/post-template.php on line 29
    [23-Aug-2013 03:12:48 America/Kentucky/Louisville] PHP Notice: Trying to get property of non-object in /home/XXXX/public_html/wp-includes/post-template.php on line 29
    [23-Aug-2013 03:12:48 America/Kentucky/Louisville] PHP Notice: Trying to get property of non-object in /home/XXXX/public_html/wp-content/themes/graphene/includes/theme-functions.php on line 10

    I can’t seem to replicate what is throwing the notices. It seems to be happening whenever a website page is viewed. I deleted the error log about three hours ago, and already it is 500 lines long… repeating that same block of code above.

    I’m wondering if it doesn’t have something to do with spammers… trying to access or leave spam comments.

    Any ideas on this one? Anyone else with similar issues in their error_logs?

    Thanks kindly!!

    Josh

    #40014

    Okay… A little further investigating shows me that these errors only appear when the theme displays the “Error 404” page.

    Also… these notices only show when wp_debug is set to true.

    I’m still at a loss… but I’ll post back if I find anything more.

    Thanks!

    Josh

    #40016

    Okay.. making progress.

    In the includes/theme-comments.php file, starting at line 194, is this function:

    function graphene_should_show_comments() {
    global $graphene_settings, $post;

    if ( $graphene_settings['comments_setting'] == 'disabled_completely' )
    return false;

    if ( $graphene_settings['comments_setting'] == 'disabled_pages' && get_post_type( $post->ID ) == 'page' )
    return false;

    if ( ! is_singular() && $graphene_settings['hide_post_commentcount'] )
    return false;

    if ( ! comments_open() && ! is_singular() && get_comments_number( $post->ID ) == 0 )
    return false;

    return true;
    }
    endif;

    The issue, I think, is that this is also running even if the page returned is a status of 404…. hence, no $POST->ID exists (or is NULL)… resulting in the errors above.

    Adjusting the function to this:

    function graphene_should_show_comments() {
    global $graphene_settings, $post;

    if ( $post->ID = NULL )
    return false; // Added to check post status of NULL

    if ( $graphene_settings['comments_setting'] == 'disabled_completely' )
    return false;

    if ( $graphene_settings['comments_setting'] == 'disabled_pages' && get_post_type( $post->ID ) == 'page' )
    return false;

    if ( ! is_singular() && $graphene_settings['hide_post_commentcount'] )
    return false;

    if ( ! comments_open() && ! is_singular() && get_comments_number( $post->ID ) == 0 )
    return false;

    return true;
    }
    endif;

    .. which just also checks the page to see if the $POST->ID is NULL, seems to correct the issue and all PHP error notices are removed.

    Do you see any issues with this code adjustment?

    Thanks Syahir!

    Admin

    Syahir Hakim

    #40017

    OK, I’ve fixed the three PHP notices that originated from within Graphene as indicated in your log file snippet above. Thanks for reporting!

    Josh

    #40018

    Thank you, Syahir!

    You rock, my friend!!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.