[wp-trac] [WordPress Trac] #48653: PHP Notices when requesting a post with an unregistered status

WordPress Trac noreply at wordpress.org
Tue Feb 4 22:13:29 UTC 2020

#48653: PHP Notices when requesting a post with an unregistered status
 Reporter:  roytanck                    |       Owner:  SergeyBiryukov
     Type:  defect (bug)                |      Status:  closed
 Priority:  normal                      |   Milestone:  5.4
Component:  Posts, Post Types           |     Version:  3.0
 Severity:  normal                      |  Resolution:  fixed
 Keywords:  has-patch needs-unit-tests  |     Focuses:
Changes (by SergeyBiryukov):

 * status:  reviewing => closed
 * resolution:   => fixed


 In [changeset:"47178" 47178]:
 #!CommitTicketReference repository="" revision="47178"
 Posts, Post Types: Fail gracefully when checking mapped cap against
 unregistered post status.

 With `map_meta_cap` enabled for a post type, the `read_post` capability
 for posts with a public status is supposed to be mapped to the post type's
 `read` capability.

 When a post is left in the database after the post status is no longer
 present, and WP does a `read_post` check against it, a PHP notice was
 thrown, and the cap check always failed.

 As a more graceful fallback, the cap is now mapped onto
 `edit_others_posts`, which allows highly privileged users to be able to
 access orphaned content.

 A `_doing_it_wrong()` notice is also added, so that developers and site
 administrators are aware that the cap mapping is failing in the absence of
 the registered post status.

 Follow-up to [34091], which introduced a similar approach to checking
 mapped caps against an unregistered post type.

 Props roytanck, SergeyBiryukov.
 Fixes #48653.

Ticket URL: <https://core.trac.wordpress.org/ticket/48653#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list