XML-RPC: calculate the proper offset for GMT in `wp.newPost`, `mw.newPost`, and `mw.editPost` when `post_date` is set, `wp.editComment` when `comment_date` is set. `post|comment_date` is assumed to be GMT. This is only true if the timezone string for the site matches GMT.

Adds unit tests for each.

Props smerriman, justdaiv, wonderboymusic.
Fixes #30429.

Built from https://develop.svn.wordpress.org/trunk@34681


git-svn-id: http://core.svn.wordpress.org/trunk@34645 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-29 04:05:24 +00:00
parent f584a3debb
commit 111c05ba47
2 changed files with 9 additions and 9 deletions

View File

@ -1324,8 +1324,8 @@ class wp_xmlrpc_server extends IXR_Server {
} }
if ( ! empty( $dateCreated ) ) { if ( ! empty( $dateCreated ) ) {
$post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) ); $post_data['post_date'] = iso8601_to_datetime( $dateCreated );
$post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' ); $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
} }
if ( ! isset( $post_data['ID'] ) ) if ( ! isset( $post_data['ID'] ) )
@ -3395,8 +3395,8 @@ class wp_xmlrpc_server extends IXR_Server {
if ( !empty( $content_struct['date_created_gmt'] ) ) { 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 // 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'; $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
$comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $comment_date = iso8601_to_datetime( $dateCreated );
$comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); $comment_date_gmt = get_gmt_from_date( $comment_date );
} }
if ( isset($content_struct['content']) ) if ( isset($content_struct['content']) )
@ -4960,8 +4960,8 @@ class wp_xmlrpc_server extends IXR_Server {
$dateCreated = $content_struct['dateCreated']->getIso(); $dateCreated = $content_struct['dateCreated']->getIso();
if ( !empty( $dateCreated ) ) { if ( !empty( $dateCreated ) ) {
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $post_date = iso8601_to_datetime( $dateCreated );
$post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); $post_date_gmt = get_gmt_from_date( $post_date );
} else { } else {
$post_date = ''; $post_date = '';
$post_date_gmt = ''; $post_date_gmt = '';
@ -5314,8 +5314,8 @@ class wp_xmlrpc_server extends IXR_Server {
$dateCreated = $content_struct['dateCreated']->getIso(); $dateCreated = $content_struct['dateCreated']->getIso();
if ( !empty( $dateCreated ) ) { if ( !empty( $dateCreated ) ) {
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $post_date = iso8601_to_datetime( $dateCreated );
$post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); $post_date_gmt = get_gmt_from_date( $post_date, 'GMT' );
} else { } else {
$post_date = $postdata['post_date']; $post_date = $postdata['post_date'];
$post_date_gmt = $postdata['post_date_gmt']; $post_date_gmt = $postdata['post_date_gmt'];

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34680'; $wp_version = '4.4-alpha-34681';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.