[wp-trac] [WordPress Trac] #52198: [PHP 8.0] Undefined property: stdClass::$post_status on /wp-admin/includes/misc.php
WordPress Trac
noreply at wordpress.org
Fri Jan 1 01:21:52 UTC 2021
#52198: [PHP 8.0] Undefined property: stdClass::$post_status on /wp-
admin/includes/misc.php
-------------------------------+-----------------------------
Reporter: GwynethLlewelyn | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 5.6
Severity: trivial | Keywords:
Focuses: |
-------------------------------+-----------------------------
I'm happily upgrading many of my WordPress installations to PHP 8.0.0 just
to see what breaks.
Here is one 'warning' that I caught today on one of my websites:
{{{
PHP Warning: Undefined property: stdClass::$post_status in <WP_PATH>/wp-
admin/includes/misc.php on line 1433
}}}
The fix is trivial, instead of
{{{#!php
<?php
if ( 'draft' === $page->post_status && 'privacy' ===
get_current_screen()->id ) {
}}}
just use
{{{#!php
<?php
if ( !empty($page->post_status) && 'draft' === $page->post_status &&
'privacy' === get_current_screen()->id ) {
}}}
... or, alternatively, use [[https://www.php.net/manual/en/function
.property-exists|property_exists()]], `isset()`, etc.
It's a very trivial change to avoid a warning; possibly it's present under
PHP 7.4 as well.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52198>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list