[wp-trac] [WordPress Trac] #47652: wp_dashboard_right_now() emits debug notices on unregistered core post types

WordPress Trac noreply at wordpress.org
Thu Jul 4 20:31:23 UTC 2019


#47652: wp_dashboard_right_now() emits debug notices on unregistered core post
types
-----------------------------+-----------------------------
 Reporter:  johnjamesjacoby  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 When you unregister a core 'post' or 'page' post type (I know... I
 know...) if they have posts in the database, the dashboard "Right Now"
 widget will output a debug notice for each unregistered type:

 {{{
 Undefined property: stdClass::$publish; wp-
 admin/includes/dashboard.php:270
 }}}

 This is because the code inside of `wp_dashboard_right_now()` always
 expects a `WP_Post_Status` object as the return type of each
 `wp_count_posts()` key, however a `stdClass` return type is also possible
 when no registered type or status is currently registered at the time the
 widget is rendered.

 ----

 Unregistering "built in" post types is normally considered to "void the
 warranty" and the `unregister_post_type()` function explicitly throws an
 error when you try, but the patch I'm about to attach is a small and bit
 of code hardening that prevents filling debug logs for those of us that
 frequently work with out-of-warranty installation types.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47652>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list