Ticket #38293: 38293.2.diff
File 38293.2.diff, 2.0 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/post.php
288 288 continue; 289 289 if ( $meta->post_id != $post_ID ) 290 290 continue; 291 if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) 292 continue; 291 293 if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) 292 294 continue; 293 295 update_meta( $key, $value['key'], $value['value'] ); -
tests/phpunit/tests/admin/includesPost.php
245 245 } 246 246 247 247 /** 248 * @ticket 38293 249 */ 250 public function test_user_cant_delete_protected_meta() { 251 $protected_meta_key = '_test_meta_data_that_is_protected'; 252 253 // Add some protected meta data. 254 $post_id = self::$post_id; 255 $meta_id = add_post_meta( $post_id, $protected_meta_key, 'protected' ); 256 257 // User editing the post should not effect outcome. 258 $expected = get_post_meta( $post_id, $protected_meta_key ); 259 260 // Attempt to edit the post. 261 wp_set_current_user( self::$admin_id ); 262 263 $post_data = array( 264 'post_ID' => $post_id, 265 'meta' => array( 266 $meta_id => array( 267 'key' => 'unprotected_meta_key', 268 'value' => 'protected', 269 ), 270 ), 271 ); 272 edit_post( $post_data ); 273 274 $actual = get_post_meta( $post_id, $protected_meta_key ); 275 $this->assertSame( $expected, $actual ); 276 277 // Tidy up. 278 delete_metadata_by_mid( 'post', $meta_id ); 279 } 280 281 /** 248 282 * @ticket 30910 249 283 */ 250 284 public function test_get_sample_permalink_should_return_pretty_permalink_for_posts_with_post_status_future() { … … 598 632 599 633 $this->assertSame( $p, post_exists( $title, $content, $date ) ); 600 634 } 635 601 636 }