XML-RPC: Revert [34681] as it broke date handling.

Merges [36163] to the 4.4 branch.

props dossy, hnle, redsweater.
see #35053, #30429 (original ticket).


git-svn-id: https://develop.svn.wordpress.org/branches/4.4@36164 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2016-01-03 19:49:34 +00:00
parent e86f49ae47
commit 7b7656950e
5 changed files with 8 additions and 107 deletions

View File

@ -1349,8 +1349,8 @@ class wp_xmlrpc_server extends IXR_Server {
}
if ( ! empty( $dateCreated ) ) {
$post_data['post_date'] = iso8601_to_datetime( $dateCreated );
$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
$post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
$post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' );
}
if ( ! isset( $post_data['ID'] ) )
@ -3423,8 +3423,8 @@ class wp_xmlrpc_server extends IXR_Server {
if ( !empty( $content_struct['date_created_gmt'] ) ) {
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
$comment_date = iso8601_to_datetime( $dateCreated );
$comment_date_gmt = get_gmt_from_date( $comment_date );
$comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
$comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
}
if ( isset($content_struct['content']) )
@ -4991,8 +4991,8 @@ class wp_xmlrpc_server extends IXR_Server {
$dateCreated = $content_struct['dateCreated']->getIso();
if ( !empty( $dateCreated ) ) {
$post_date = iso8601_to_datetime( $dateCreated );
$post_date_gmt = get_gmt_from_date( $post_date );
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
$post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
} else {
$post_date = '';
$post_date_gmt = '';
@ -5345,8 +5345,8 @@ class wp_xmlrpc_server extends IXR_Server {
$dateCreated = $content_struct['dateCreated']->getIso();
if ( !empty( $dateCreated ) ) {
$post_date = iso8601_to_datetime( $dateCreated );
$post_date_gmt = get_gmt_from_date( $post_date, 'GMT' );
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
$post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
} else {
$post_date = $postdata['post_date'];
$post_date_gmt = $postdata['post_date_gmt'];

View File

@ -219,32 +219,6 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
$this->assertEquals( $result->code, 401 );
}
/**
* @ticket 30429
*/
function test_post_date_timezone_conversion() {
$tz = get_option( 'timezone_string' );
update_option( 'timezone_string', 'America/New_York' );
$editor_id = $this->make_user_by_role( 'editor' );
$post_id = self::factory()->post->create( array(
'post_author' => $editor_id
) );
$date_string = '1984-01-11 05:00:00';
$result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array(
'dateCreated' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) ),
) ) );
$fetched_post = get_post( $post_id );
update_option( 'timezone_string', $tz );
$this->assertTrue( $result );
$this->assertEquals( $date_string, $fetched_post->post_date );
}
/**
* @ticket 16980
*/

View File

@ -170,27 +170,4 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
$this->assertEquals( 'draft', $out->post_status );
$this->assertEquals( '0000-00-00 00:00:00', $out->post_date_gmt );
}
/**
* @ticket 30429
*/
function test_post_date_timezone_conversion() {
$tz = get_option( 'timezone_string' );
update_option( 'timezone_string', 'America/New_York' );
$this->make_user_by_role( 'editor' );
$date_string = '1984-01-11 05:00:00';
$post = array(
'title' => 'test',
'post_content' => 'test',
'dateCreated' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) )
);
$result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
$fetched_post = get_post( $result );
update_option( 'timezone_string', $tz );
$this->assertStringMatchesFormat( '%d', $result );
$this->assertEquals( $date_string , $fetched_post->post_date );
}
}

View File

@ -69,36 +69,4 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase {
$this->assertEquals( 'trash', get_comment( $comment_id )->comment_approved );
}
/**
* @ticket 30429
*/
function test_post_date_timezone_conversion() {
$tz = get_option( 'timezone_string' );
update_option( 'timezone_string', 'America/New_York' );
$this->make_user_by_role( 'administrator' );
$post_id = self::factory()->post->create();
$comment_data = array(
'comment_post_ID' => $post_id,
'comment_author' => 'Test commenter',
'comment_author_url' => 'http://example.com/',
'comment_author_email' => 'example@example.com',
'comment_content' => rand_str( 100 ),
'comment_approved' => '1',
);
$comment_id = wp_insert_comment( $comment_data );
$date_string = '1984-01-11 05:00:00';
$result = $this->myxmlrpcserver->wp_editComment( array( 1, 'administrator', 'administrator', $comment_id, array(
'date_created_gmt' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) )
) ) );
$fetched_comment = get_comment( $comment_id );
update_option( 'timezone_string', $tz );
$this->assertTrue( $result );
$this->assertEquals( $date_string, $fetched_comment->comment_date );
}
}

View File

@ -373,22 +373,4 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
$this->assertEquals( $date_string , $fetched_post->post_date_gmt );
}
/**
* @ticket 30429
*/
function test_post_date_timezone_conversion() {
$tz = get_option( 'timezone_string' );
update_option( 'timezone_string', 'America/New_York' );
$this->make_user_by_role( 'author' );
$date_string = '1984-01-11 05:00:00';
$post = array( 'post_title' => 'test', 'post_content' => 'test', 'post_date' => $date_string );
$result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
$fetched_post = get_post( $result );
update_option( 'timezone_string', $tz );
$this->assertStringMatchesFormat( '%d', $result );
$this->assertEquals( $date_string , $fetched_post->post_date );
}
}