• Hi,

    I’m having an issue where if WP_DEBUG is enabled, the error log becomes filled with the following error:

    [06-Jan-2020 02:47:41 UTC] PHP Notice:  Trying to get property 'ID' of non-object in /home/---/public_html/wp-content/plugins/tracking-script-manager/tracking-scripts-manager.php on line 173
    [06-Jan-2020 02:47:41 UTC] PHP Notice:  Trying to get property 'ID' of non-object in /home/---/public_html/wp-content/plugins/tracking-script-manager/tracking-scripts-manager.php on line 259
    [06-Jan-2020 02:47:41 UTC] PHP Notice:  Trying to get property 'ID' of non-object in /home/---/public_html/wp-content/plugins/tracking-script-manager/tracking-scripts-manager.php on line 216
    

    The problem seems to be that the plugin is not properly checking if $wp_query->post is set in several hooks.

    As far as I can tell, scripts are only added to single posts or pages, so a better solution would be to combine is_singular() with get_queried_object_id().

    I’d suggest replacing:

    global $wp_query;
    $current_id = $wp_query->post->ID;
    

    With:

    $current_id = is_singular() ? get_queried_object_id() : null;
    
  • The topic ‘Filling up error log when WP_DEBUG is enabled’ is closed to new replies.