From 470110ec3dbb412c3b93b9464a0830d01072d550 Mon Sep 17 00:00:00 2001 From: Rachel Baker Date: Tue, 22 Mar 2016 15:10:28 +0000 Subject: [PATCH] =?UTF-8?q?XMLRPC:=20Fix=20bug=20where=20draft=20posts=20c?= =?UTF-8?q?ouldn=E2=80=99t=20be=20published=20in=20the=20future,=20and=20w?= =?UTF-8?q?ould=20publish=20immediately.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves bug introduced in [r34572], in which editing a Post via the XMLRPC API with a draft post_status, where the post_status changes from draft->publish with a future post_date set for the publish action, will have the future post_date disregarded and the Post will be published immediately. The expected behavior is that the post_date is used to schedule the Post to be published in the future. Fixes #35874. Props redsweater, rachelbaker, DrewAPicture Built from https://develop.svn.wordpress.org/trunk@37043 git-svn-id: http://core.svn.wordpress.org/trunk@37010 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 14 +++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index c035bb57b9..531dd50c9e 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -1364,9 +1364,15 @@ class wp_xmlrpc_server extends IXR_Server { $dateCreated = $post_data['post_date']->getIso(); } + // Default to not flagging the post date to be edited unless it's intentional. + $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' ); + + // Flag the post date to be edited. + $post_data['edit_date'] = true; } if ( ! isset( $post_data['ID'] ) ) @@ -5375,16 +5381,22 @@ class wp_xmlrpc_server extends IXR_Server { elseif ( !empty( $content_struct['dateCreated']) ) $dateCreated = $content_struct['dateCreated']->getIso(); + // Default to not flagging the post date to be edited unless it's intentional. + $edit_date = false; + if ( !empty( $dateCreated ) ) { $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); + + // Flag the post date to be edited. + $edit_date = true; } else { $post_date = $postdata['post_date']; $post_date_gmt = $postdata['post_date_gmt']; } // We've got all the data -- post it. - $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'); + $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'); $result = wp_update_post($newpost, true); if ( is_wp_error( $result ) ) diff --git a/wp-includes/version.php b/wp-includes/version.php index debb6229c2..87f7eab259 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-beta4-37042'; +$wp_version = '4.5-beta4-37043'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.