XML-RPC: Make sure editing a draft post with wp.editPost does not unintentionally cause its published date to be set.

Props redsweater.
Fixes #45322.
Built from https://develop.svn.wordpress.org/trunk@45906


git-svn-id: http://core.svn.wordpress.org/trunk@45717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-08-29 02:10:56 +00:00
parent 27a384caa4
commit e0adbf69ff
2 changed files with 11 additions and 1 deletions

View File

@ -1708,6 +1708,16 @@ class wp_xmlrpc_server extends IXR_Server {
$post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] ); $post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] );
} }
/*
* If the API client did not provide post_date, then we must not perpetuate the value that was
* stored in the database, or it will appear to be an intentional edit. Conveying it here as if
* it was coming from the API client will cause an otherwise zeroed out post_date_gmt to get set
* with the value that was originally stored in the database when the draft was created.
*/
if ( ! isset( $content_struct['post_date'] ) ) {
unset( $post['post_date'] );
}
$this->escape( $post ); $this->escape( $post );
$merged_content_struct = array_merge( $post, $content_struct ); $merged_content_struct = array_merge( $post, $content_struct );

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3-alpha-45905'; $wp_version = '5.3-alpha-45906';
/** /**
* 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.