Ticket #35874: 35874.diff
File 35874.diff, 4.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-xmlrpc-server.php
1364 1364 $dateCreated = $post_data['post_date']->getIso(); 1365 1365 } 1366 1366 1367 // Indicate to `wp_update_post` whether an intentional edit is being made to the post date(s). 1368 $post_data['edit_date'] = false; 1367 1369 if ( ! empty( $dateCreated ) ) { 1368 1370 $post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) ); 1369 1371 $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' ); 1372 1373 $post_data['edit_date'] = true; 1370 1374 } 1371 1375 1372 1376 if ( ! isset( $post_data['ID'] ) ) … … 5375 5379 elseif ( !empty( $content_struct['dateCreated']) ) 5376 5380 $dateCreated = $content_struct['dateCreated']->getIso(); 5377 5381 5382 // Indicate to `wp_update_post` whether an intentional edit is being made to the post date(s). 5383 $edit_date = false; 5378 5384 if ( !empty( $dateCreated ) ) { 5379 5385 $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); 5380 5386 $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); 5387 5388 $edit_date = true; 5381 5389 } else { 5382 5390 $post_date = $postdata['post_date']; 5383 5391 $post_date_gmt = $postdata['post_date_gmt']; … … 5384 5392 } 5385 5393 5386 5394 // We've got all the data -- post it. 5387 $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', ' post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template');5395 $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'edit_date', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template'); 5388 5396 5389 5397 $result = wp_update_post($newpost, true); 5390 5398 if ( is_wp_error( $result ) ) -
tests/phpunit/tests/xmlrpc/mw/editPost.php
241 241 $tags2 = get_the_tags( $post_id ); 242 242 $this->assertEmpty( $tags2 ); 243 243 } 244 245 /** 246 * @ticket 35874 247 */ 248 function test_draft_not_prematurely_published() { 249 $editor_id = $this->make_user_by_role( 'editor' ); 250 251 $post = array( 252 'title' => 'Title', 253 ); 254 255 /** 256 * We have to use wp_newPost method, rather than the factory 257 * post->create method to create the database conditions that exhibit 258 * the bug. 259 */ 260 $post_id = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); 261 262 // Change the post's status to publish and date to future. 263 $future_time = strtotime( '+1 day' ); 264 $future_date = new IXR_Date( $future_time ); 265 $this->myxmlrpcserver->mw_editPost( array( 266 $post_id, 267 'editor', 268 'editor', 269 array( 270 'dateCreated' => $future_date, 271 'post_status' => 'publish', 272 ), 273 ) ); 274 275 $after = get_post( $post_id ); 276 $this->assertEquals( 'future', $after->post_status ); 277 278 $future_date_string = strftime( '%Y-%m-%d %H:%M:%S', $future_time ); 279 $this->assertEquals( $future_date_string, $after->post_date ); 280 } 244 281 } -
tests/phpunit/tests/xmlrpc/wp/editPost.php
401 401 // Check that the old enclosure is in the enclosure meta 402 402 $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ) ) ); 403 403 } 404 405 /** 406 * @ticket 35874 407 */ 408 function test_draft_not_prematurely_published() { 409 $editor_id = $this->make_user_by_role( 'editor' ); 410 411 /** 412 * We have to use wp_newPost method, rather than the factory 413 * post->create method to create the database conditions that exhibit 414 * the bug. 415 */ 416 $post = array( 417 'post_title' => 'Test', 418 'post_status' => 'draft', 419 ); 420 $post_id = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); 421 422 // Change the post's status to publish and date to future. 423 $future_time = strtotime( '+1 day' ); 424 $future_date = new IXR_Date( $future_time ); 425 $new_post_content = array( 426 'ID' => $post_id, 427 'post_title' => 'Updated', 428 'post_status' => 'publish', 429 'post_date' => $future_date, 430 ); 431 432 $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) ); 433 434 $after = get_post( $post_id ); 435 $this->assertEquals( 'future', $after->post_status ); 436 437 $future_date_string = strftime( '%Y-%m-%d %H:%M:%S', $future_time ); 438 $this->assertEquals( $future_date_string, $after->post_date ); 439 } 404 440 }