From 1cdaf142f2bb450eaa368162065e5d6b145ceb22 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 9 Dec 2019 20:08:06 +0000 Subject: [PATCH] =?UTF-8?q?Date/Time:=20XML-RPC:=20=D0=A1alculate=20the=20?= =?UTF-8?q?proper=20offset=20for=20GMT=20in=20`wp.newPost`,=20`wp.editComm?= =?UTF-8?q?ent`,=20`mw.newPost`,=20`mw.editPost`=20when=20`post=5Fdate`=20?= =?UTF-8?q?or=20`comment=5Fdate`=20is=20set.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, `post_date` or `comment_date` was assumed to be GMT, which is only true if the timezone string for the site matches GMT. Add unit tests. Props Rarst, smerriman, justdaiv, wonderboymusic, noyle. Merges [46864] to the 5.3 branch. Fixes #30429. Built from https://develop.svn.wordpress.org/branches/5.3@46865 git-svn-id: http://core.svn.wordpress.org/branches/5.3@46665 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 16 ++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index abef0329ef..5b3d514d96 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -1469,8 +1469,8 @@ class wp_xmlrpc_server extends IXR_Server { $post_data['edit_date'] = false; if ( ! empty( $dateCreated ) ) { - $post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) ); - $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' ); + $post_data['post_date'] = iso8601_to_datetime( $dateCreated ); + $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' ); // Flag the post date to be edited. $post_data['edit_date'] = true; @@ -3762,8 +3762,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['comment_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) ); - $comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' ); + $comment['comment_date'] = get_date_from_gmt( $dateCreated ); + $comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' ); } if ( isset( $content_struct['content'] ) ) { @@ -5481,8 +5481,8 @@ class wp_xmlrpc_server extends IXR_Server { } if ( ! empty( $dateCreated ) ) { - $post_date = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) ); - $post_date_gmt = iso8601_to_datetime( $dateCreated, 'GMT' ); + $post_date = iso8601_to_datetime( $dateCreated ); + $post_date_gmt = iso8601_to_datetime( $dateCreated, 'gmt' ); } else { $post_date = ''; $post_date_gmt = ''; @@ -5870,8 +5870,8 @@ class wp_xmlrpc_server extends IXR_Server { $edit_date = false; if ( ! empty( $dateCreated ) ) { - $post_date = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) ); - $post_date_gmt = iso8601_to_datetime( $dateCreated, 'GMT' ); + $post_date = iso8601_to_datetime( $dateCreated ); + $post_date_gmt = iso8601_to_datetime( $dateCreated, 'gmt' ); // Flag the post date to be edited. $edit_date = true; diff --git a/wp-includes/version.php b/wp-includes/version.php index 5b853b154f..249bd1f3b7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3.1-alpha-46863'; +$wp_version = '5.3.1-alpha-46865'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.