Make WordPress Core

Opened 18 months ago

Last modified 18 months ago

#26365 new defect (bug)

map_meta_cap() should use parent post status when post has a post status of inherit

Reported by: methnen Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.8
Component: Role/Capability Keywords: 2nd-opinion has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

When a post has a status of inherit map_meta_cap() fails to use the parent's status and so logic that uses the status to determine the mapping doesn't behave as expected.

For example read_post() will often fail when it should pass. Similarly for delete_post() and edit_post().

This has recently caused a variety of difficulties in a project I've been working on where we have a custom post type that uses the inherit post status on children so authors only need to manage the post status of the main parent post.

The fix is two parts. One a fix to get_post_status() that causes it to check the parent status so it'll work backwards to the first post that has a valid (not 'inherit') post status.

The second is a fix to map_meta_cap() that checks for a post status of inherit on the post object and then uses get_post_status() on the post_parent id value.

A couple related/similar issues:
#23458 (these patches would fix the root issue)
#17668 (fixed)

Attachments (2)

capabilities.diff (1.3 KB) - added by methnen 18 months ago.
post.diff (511 bytes) - added by methnen 18 months ago.

Download all attachments as: .zip

Change History (7)

@methnen18 months ago


@methnen18 months ago


comment:1 @misterbisson18 months ago

  • Keywords has-patch added

+1 one this. I'm biased because we need this to resolve the bugs named above. We make extensive use of custom post types with inherit status on a number of gigaom.com properties.

comment:2 @misterbisson18 months ago

  • Keywords needs-patch 2nd-opinion added; has-patch removed

comment:3 @misterbisson18 months ago

  • Keywords needs-patch removed

comment:4 @misterbisson18 months ago

  • Keywords has-patch added

comment:5 @SergeyBiryukov18 months ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.