From 81b8b6cfbc9ee33a4a491ffcd9584ef3384e59c1 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 26 Jun 2014 17:43:14 +0000 Subject: [PATCH] XML-RPC: Make sure wp.newPost does not produce a fatal error when a post_date field is included in the data. props dllh. fixes #28601. Built from https://develop.svn.wordpress.org/trunk@28854 git-svn-id: http://core.svn.wordpress.org/trunk@28657 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index e8a70ff206..bad5c47844 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -1102,6 +1102,21 @@ class wp_xmlrpc_server extends IXR_Server { if ( ! $user = $this->login( $username, $password ) ) return $this->error; + // convert the date field back to IXR form + if ( isset( $content_struct['post_date'] ) ) { + $content_struct['post_date'] = $this->_convert_date( $content_struct['post_date'] ); + } + + // ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct, + // since _insert_post will ignore the non-GMT date if the GMT date is set + if ( isset( $content_struct['post_date_gmt'] ) ) { + if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { + unset( $content_struct['post_date_gmt'] ); + } else { + $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); + } + } + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.newPost' );