Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice: Trying to get property of non-object in \wp-content\plugins\wordpress-seo\inc\class-wpseo-meta.php on line 393 / 394 / 395 #9584

Closed
2 tasks done
toddlevy opened this issue Apr 27, 2018 · 8 comments

Comments

@toddlevy
Copy link

toddlevy commented Apr 27, 2018

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

When trying to "quick edit" a post, the admin table's checkbox column gets populated with a series of PHP notices:

Notice: Trying to get property of non-object in F:\www\sbf2017\wp-content\plugins\wordpress-seo\inc\class-wpseo-meta.php on line 393
Notice: Trying to get property of non-object in F:\www\sbf2017\wp-content\plugins\wordpress-seo\inc\class-wpseo-meta.php on line 394
Notice: Trying to get property of non-object in F:\www\sbf2017\wp-content\plugins\wordpress-seo\inc\class-wpseo-meta.php on line 395

screenshot-sbf2017 localdev-2018 04 27-12-16-38

Please describe what you expected to happen and why.

Expected no error messages and the row of post data to reappear after the quick edit form went away.

How can we reproduce this behavior?

  1. Turn on all error reporting at top of functions.php...

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

NOTE: Normally wouldn't "hack" a theme but this is the minimal way to recreate.

  1. Go to Admin > All Posts

  2. Choose "Quick Edit" and make a change. (assumes an existing post)

  3. Click "Update"

Technical info

  • WordPress version: 4.9.5
  • Yoast SEO version: 7.3
  • Relevant plugins in case of a bug: Only Yoast SEO active
  • Tested with theme: Twenty SeventeenVersion: 1.5
@benvaassen
Copy link
Contributor

Thanks for reporting this bug!
I’ve marked it as backlog so it appears on the to-do list for our developers.

@Beee4life
Copy link

Beee4life commented Aug 11, 2018

I experienced this for quite a while... just as I deduce why it happened I found this post :)

I do a similar thing but use it in a class/function as follows:

add_action( 'after_setup_theme', array( $this, 'sd_setup_error_logging' ) );

public function sd_setup_error_logging() {
    if ( WP_DEBUG ) {
        // E_DEPRECATED is a core PHP constant in PHP 5.3. Don't define this yourself.
        // The two statements are equivalent, just one is for 5.3+ and for less than 5.3.
        if ( defined( 'E_DEPRECATED' ) ) {
            error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
        } else {
            die('HERE');
            error_reporting( E_ALL );
        }

        if ( WP_DEBUG_DISPLAY ) {
            ini_set( 'display_errors', 1 );
        } elseif ( null !== WP_DEBUG_DISPLAY ) {
            ini_set( 'display_errors', 0 );
        }

        if ( WP_DEBUG_LOG ) {
            ini_set( 'log_errors', 1 );
            // @TODO: check if exists
            // @mkdir(WP_CONTENT_DIR . '/log/', 0755, true);
            ini_set( 'error_log', WP_CONTENT_DIR . '/log/debug.' . date( 'Y-m-d', time() ) . '.log' );
        }
    } else {
        error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
    }
}

I deduced that global $post on line 376 returns null, but I can't figure out why...

It's not a problem, but I would prefer to not have the warning ;)

@Beee4life
Copy link

When I deactivate this function, the warning doesn't show, but it does get logged (in debug.log).

@eugenealegiojo
Copy link

Experiencing this issue as well. I guess advanced tab logic is not applicable for the quick edit.

@moorscode
Copy link
Contributor

Looking at the code referenced in the original report, the lines have changed.
I'm assuming the problem has been solved in the meanwhile.

@eugenealegiojo if you can provide the specific error messages and a Yoast SEO version this occurs in we can solve the issue.

@eugenealegiojo
Copy link

@moorscode The specific error is the same in the issue description except for the line number.

But it looks fixed with the recent release 9.1. I think this line Fixes a bug where notices were being thrown when quick editing a post and no post type object could be found.

@benvaassen
Copy link
Contributor

If it's not fixed, please let us know and we'll reopen. For now, I'm going to close this because it seems to be fixed with 9.1.

@Beee4life
Copy link

I don't get the error anymore...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants