HongPong / broken-link-checker

This plugin will check your posts, comments and other content for broken links and missing images, and notify you if any are found. (non-commercial community fork of broken-link-checker)
10 stars 4 forks source link

Notice: Trying to get property of non-object in hook_the_content() #33

Open HongPong opened 5 years ago

HongPong commented 5 years ago

reported by @johnny538 a few months ago here https://wordpress.org/support/topic/php-errors-135/

PHP Notice: Trying to get property of non-object in /var/www/html/wp-content/plugins/broken-link-checker/includes/any-post.php on line 298

please fix

a lot of times this kind of notice can be fixed by isset() or property_exists() , however not sure if that would matter because $post is checked for emptiness first ( http://php.net/manual/en/function.empty.php ) . Maybe post is somehow not an object here.

see also https://wordpress.stackexchange.com/questions/88613/notice-trying-to-get-property-of-non-object-in-options-php

looks to me like this

        if ( empty($post) || !in_array($post->post_type, $this->enabled_post_types)) {

Perhaps $post is not empty and $this is unset. That would lead to this condition. More careful checking of the nature of $this may be needed since this could be triggered in an odd place?