Jetpack: Widget Visibility: PHP Notice: Undefined property: stdClass::$post_status

Created on 29 Jan 2021  路  11Comments  路  Source: Automattic/jetpack

Seeing PHP Notice: Undefined property: stdClass::$post_status in /srv/www/gitwooplugins/public_html/wp-admin/includes/misc.php on line 1433

For every page that is on the site.

Steps to reproduce the issue

  1. Activate the Jetpack (9.3.1) and ensure no other plugins are activated.
  2. Go to Appearance->Widgets settings page.
  3. See the PHP notice (mentioned above) in the logs. It will log one notice for every page that exists on the site.
  4. Do the same test without Jetpack enabled, no more notices.

Other reports I've seen in the wild - https://wordpress.org/support/topic/error-in-wp-admin-includes-misc-php-on-line-1433/

What I expected

I am expecting to see no notices in the PHP logs.

What happened instead

I am seeing notices.

Screenshots
If applicable, add screenshots to help explain your problem.

Widget Visibility [Pri] Normal [Type] Bug [Type] Happiness Request

All 11 comments

Thanks for the report. I can't seem to be able to reproduce on my end at the moment, so there must be something different between your set up and mine? Is this happening on a test site of yours? If so, would you be able to get a stack trace of the error, so we can find out more about what's causing this?

If that's not an option, could you let me know what Jetpack modules are currently active on your site?If you go to wp-admin/admin.php?page=jetpack_modules you should get a full list.

Thank you!

Yes it is on a dev setup. So these are PHP notices so I don't think it has backtraces at least my environment is not configured to do so. But if it helps, Jetpack is in "Offline" mode.

Update: Ok so if I deactivate Widget Visibility, the notices go away.

If it helps - the notice is generated when this happens https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/misc.php#L1433

Basically that check is expecting $page to be a WP Post object. But instead the pages are coming as stdClass objects. Thus post_status property doesn't exist.

Related: #17434

Basically that check is expecting $page to be a WP Post object. But instead the pages are coming as stdClass objects. Thus post_status property doesn't exist.

Do you know if you have a plugin on your site that may make that change?

Do you know if you have a plugin on your site that may make that change?

Only Jetpack is active during my test.

cc @david-binda, who worked on #17434.

@jeherve Here's a stack trace (edit: this is from clicking on 'Customize', which is where I saw the notice myself):

_wp_privacy_settings_filter_draft_page_titles (/Users/wunc/Sites/wordpress/web/wp/wp-admin/includes/misc.php:1433)
WP_Hook->apply_filters (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-hook.php:287)
apply_filters (/Users/wunc/Sites/wordpress/web/wp/wp-includes/plugin.php:212)
Walker_PageDropdown->start_el (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-walker-page-dropdown.php:86)
Walker_PageDropdown->display_element (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-walker.php:144)
Walker_PageDropdown->walk (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-walker.php:244)
walk_page_dropdown_tree (/Users/wunc/Sites/wordpress/web/wp/wp-includes/post-template.php:1563)
Jetpack_Widget_Conditions::widget_admin_setup (/Users/wunc/Sites/wordpress/web/app/plugins/jetpack/modules/widget-visibility/widget-conditions.php:169)
WP_Hook->apply_filters (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-hook.php:287)
WP_Hook->do_action (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-hook.php:311)
do_action (/Users/wunc/Sites/wordpress/web/wp/wp-includes/plugin.php:484)
WP_Customize_Widgets->customize_controls_init (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-customize-widgets.php:340)
WP_Hook->apply_filters (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-hook.php:287)
WP_Hook->do_action (/Users/wunc/Sites/wordpress/web/wp/wp-includes/class-wp-hook.php:311)
do_action (/Users/wunc/Sites/wordpress/web/wp/wp-includes/plugin.php:484)
require (/Users/wunc/Sites/wordpress/web/wp/wp-admin/customize.php:112)
{main} (/Users/wunc/.composer/vendor/laravel/valet/server.php:219)

Digging into it, shows that Jetpack_Widget_Conditions@get_pages() indeed creates an array of StdClass objects with only ID, post_parent, and post_title fields. So, that's why $page doesn't have a "post_status" property when it gets to that filter _wp_privacy_settings_filter_draft_page_titles() line 1433 later.

One possible fix would be to just add {$wpdb->posts}.post_status to the SELECT on line 260. I can confirm that if I make this change locally, the PHP Notice goes away.

Another report on this in 3840136-zd-woothemes. I've asked them to try disabling the visibility widget to test this and check for any plugin or theme conflicts.

Was this page helpful?
0 / 5 - 0 ratings