Changeset 34113
- Timestamp:
- 09/14/2015 04:43:48 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/capabilities-functions.php
r34091 r34113 48 48 case 'delete_page': 49 49 $post = get_post( $args[0] ); 50 if ( ! $post ) { 51 $caps[] = 'do_not_allow'; 52 break; 53 } 50 54 51 55 if ( 'revision' == $post->post_type ) { 52 56 $post = get_post( $post->post_parent ); 57 if ( ! $post ) { 58 $caps[] = 'do_not_allow'; 59 break; 60 } 53 61 } 54 62 … … 98 106 case 'edit_page': 99 107 $post = get_post( $args[0] ); 100 if ( empty( $post )) {108 if ( ! $post ) { 101 109 $caps[] = 'do_not_allow'; 102 110 break; … … 105 113 if ( 'revision' == $post->post_type ) { 106 114 $post = get_post( $post->post_parent ); 115 if ( ! $post ) { 116 $caps[] = 'do_not_allow'; 117 break; 118 } 107 119 } 108 120 … … 150 162 case 'read_page': 151 163 $post = get_post( $args[0] ); 164 if ( ! $post ) { 165 $caps[] = 'do_not_allow'; 166 break; 167 } 152 168 153 169 if ( 'revision' == $post->post_type ) { 154 170 $post = get_post( $post->post_parent ); 171 if ( ! $post ) { 172 $caps[] = 'do_not_allow'; 173 break; 174 } 155 175 } 156 176 … … 187 207 case 'publish_post': 188 208 $post = get_post( $args[0] ); 209 if ( ! $post ) { 210 $caps[] = 'do_not_allow'; 211 break; 212 } 213 189 214 $post_type = get_post_type_object( $post->post_type ); 190 215 if ( ! $post_type ) { … … 201 226 case 'add_post_meta': 202 227 $post = get_post( $args[0] ); 228 if ( ! $post ) { 229 $caps[] = 'do_not_allow'; 230 break; 231 } 232 203 233 $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); 204 234 … … 230 260 case 'edit_comment': 231 261 $comment = get_comment( $args[0] ); 232 if ( empty( $comment ) ) 233 break; 262 if ( ! $comment ) { 263 $caps[] = 'do_not_allow'; 264 break; 265 } 266 234 267 $post = get_post( $comment->comment_post_ID ); 235 268 -
trunk/tests/phpunit/tests/user/mapMetaCap.php
r31622 r34113 36 36 unset( $GLOBALS['wp_post_types'][ $this->post_type ] ); 37 37 parent::tearDown(); 38 } 39 40 /** 41 * @ticket 13905 42 */ 43 function test_capability_type_post_with_invalid_id() { 44 $this->assertEquals( 45 array( 'do_not_allow' ), 46 map_meta_cap( 'edit_post', $this->user_id, $this->post_id + 1 ) 47 ); 38 48 } 39 49
Note: See TracChangeset
for help on using the changeset viewer.