Make WordPress Core

Opened 10 years ago

Closed 7 years ago

#31034 closed defect (bug) (worksforme)

delete_post capability issue in Trash

Reported by: szaqal21's profile szaqal21 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: Posts, Post Types Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

There is a issue with capability 'delete_post' in Trash when a post with status other than 'publish' was trashed. When you registered this post type with map_meta_cap => true and disabled capability 'delete_post' using 'user_has_cap' you will see that in posts (view All) table there is no trash link in post row actions but you can select this post and bulk remove. Post will be moved to trash and voila in view Trash you can permanently remove this post.

I've checked the source and found that te problem is map_meta_cap() function

} elseif ( 'trash' == $post->post_status ) {
				if ( 'publish' == get_post_meta( $post->ID, '_wp_trash_meta_status', true ) ) {
					$caps[] = $post_type->cap->delete_published_posts;
				}
			}

there is a check for 'publish' status so when my post was 'pending' map_meta_cap() returned empty array().

Change History (4)

#1 @SergeyBiryukov
10 years ago

  • Component changed from Role/Capability to Posts, Post Types

#2 follow-up: @DrewAPicture
7 years ago

  • Keywords needs-patch needs-unit-tests added

@szaqal21 Would you be interested in submitting a patch to address this? We'd probably also need accompanying unit tests.

#3 in reply to: ↑ 2 @szaqal21
7 years ago

Replying to DrewAPicture:

@szaqal21 Would you be interested in submitting a patch to address this? We'd probably also need accompanying unit tests.

I've checked and it has been fixed in version 4.4.

#4 @johnbillion
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.