[wp-trac] [WordPress Trac] #14122: Custom "capabilities" appears broken on custom post types

WordPress Trac wp-trac at lists.automattic.com
Wed Nov 10 13:13:00 UTC 2010


#14122: Custom "capabilities" appears broken on custom post types
----------------------------+-----------------------------------------------
 Reporter:  jakemgold       |       Owner:  nacin                       
     Type:  task (blessed)  |      Status:  assigned                    
 Priority:  normal          |   Milestone:  3.1                         
Component:  Post Types      |     Version:  3.0                         
 Severity:  normal          |    Keywords:  needs-patch needs-unit-tests
----------------------------+-----------------------------------------------
Changes (by nacin):

  * keywords:  needs-patch => needs-patch needs-unit-tests


Comment:

 Here's a big issue with 3.0 functionality.
 {{{
 {{{
 register_post_type( 'book', array(
                 'capability_type' => 'post',
                 'capabilities' => array( 'edit_post' => 'edit_book' ),
         )
 );
 $user_id = 1;
 $post_id = wp_insert_post( array( 'post_title' => 'book', 'post_type' =>
 'book', 'post_status' => 'private', 'post_author' => 1 ) );
 var_dump( map_meta_cap( 'edit_post', $user_id, $post_id ) );
 $post_type_obj = get_post_type_object( 'book' );
 var_dump( map_meta_cap( $post_type_obj->cap->edit_post, 1, $post_id ) );
 }}}
 You should get two arrays that match. They won't, though. Checking through
 the post type cap will give you edit_book (no mapping), but checking
 through edit_post will give you edit_private_posts based on the faulty
 meta cap.

 The bug everyone has been seeing is caused by a direct edit_post call in
 the list table. While core shouldn't have any of these, we need to remain
 compat for plugins. They should work the same.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14122#comment:43>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list