XML-RPC: In wp_xmlrpc_server::mw_newPost(), if $dateCreated is not set, don't set post_date and post_date_gmt. It calls wp_insert_post(), which will handle it correctly. The problem was drafts being created and GMT date being set. It shouldn't be.

Adds unit test.

Fixes #16985.


git-svn-id: https://develop.svn.wordpress.org/trunk@34572 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-09-26 03:37:53 +00:00
parent faad66d510
commit 9cf6b6f2d0
2 changed files with 23 additions and 2 deletions

View File

@@ -4931,8 +4931,8 @@ class wp_xmlrpc_server extends IXR_Server {
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
$post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
} else {
$post_date = current_time('mysql');
$post_date_gmt = current_time('mysql', 1);
$post_date = '';
$post_date_gmt = '';
}
$post_category = array();

View File

@@ -159,4 +159,25 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
$this->assertEquals( 'page', $out->post_type );
}
/**
* @ticket 16985
*/
function test_draft_post_date() {
$this->make_user_by_role( 'editor' );
$post = array(
'title' => 'Test',
'post_type' => 'post',
'post_status' => 'draft'
);
$result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
$this->assertNotInstanceOf( 'IXR_Error', $result );
$this->assertStringMatchesFormat( '%d', $result );
$out = get_post( $result );
$this->assertEquals( 'post', $out->post_type );
$this->assertEquals( 'draft', $out->post_status );
$this->assertEquals( '0000-00-00 00:00:00', $out->post_date_gmt );
}
}