Changeset 47178
- Timestamp:
- 02/04/2020 10:13:15 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/capabilities.php
r47122 r47178 242 242 243 243 $status_obj = get_post_status_object( $post->post_status ); 244 if ( ! $status_obj ) { 245 /* translators: 1: Post status, 2: Capability name. */ 246 _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post status %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post with that status.' ), $post->post_status, $cap ), '5.4.0' ); 247 $caps[] = 'edit_others_posts'; 248 break; 249 } 250 244 251 if ( $status_obj->public ) { 245 252 $caps[] = $post_type->cap->read; -
trunk/tests/phpunit/tests/user/capabilities.php
r47122 r47178 1775 1775 1776 1776 /** 1777 * @ticket 48653 1778 * @expectedIncorrectUsage map_meta_cap 1779 */ 1780 function test_require_edit_others_posts_if_post_status_doesnt_exist() { 1781 register_post_status( 'existed' ); 1782 $post_id = self::factory()->post->create( array( 'post_status' => 'existed' ) ); 1783 _unregister_post_status( 'existed' ); 1784 1785 $subscriber_id = self::$users['subscriber']->ID; 1786 $editor_id = self::$users['editor']->ID; 1787 1788 foreach ( array( 'read_post', 'read_page' ) as $cap ) { 1789 wp_set_current_user( $subscriber_id ); 1790 $this->assertSame( array( 'edit_others_posts' ), map_meta_cap( $cap, $subscriber_id, $post_id ) ); 1791 $this->assertFalse( current_user_can( $cap, $post_id ) ); 1792 1793 wp_set_current_user( $editor_id ); 1794 $this->assertSame( array( 'edit_others_posts' ), map_meta_cap( $cap, $editor_id, $post_id ) ); 1795 $this->assertTrue( current_user_can( $cap, $post_id ) ); 1796 } 1797 } 1798 1799 /** 1777 1800 * @ticket 17253 1778 1801 */
Note: See TracChangeset
for help on using the changeset viewer.