Ticket #18429: convert_date.patch
File convert_date.patch, 2.7 KB (added by , 13 years ago) |
---|
-
wp-includes/class-wp-xmlrpc-server.php
467 467 } 468 468 469 469 /** 470 * Convert a WordPress date string to an IXR_Date object. 471 * 472 * @access protected 473 * 474 * @param $date 475 * @return IXR_Date 476 */ 477 protected function _convert_date( $date ) { 478 if ( $date === '0000-00-00 00:00:00' ) { 479 return new IXR_Date( '00000000T00:00:00Z' ); 480 } 481 return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) ); 482 } 483 484 /** 470 485 * Prepares post data for return in an XML-RPC object. 471 486 * 472 487 * @access private … … 477 492 */ 478 493 function _prepare_post( $post, $fields ) { 479 494 // holds the data for this post. built up based on $fields 480 $_post = array( 'post_id' => $post['ID']);495 $_post = array( 'post_id' => strval( $post['ID'] ) ); 481 496 482 497 // prepare common post fields 483 498 $post_fields = array( 484 499 'post_title' => $post['post_title'], 485 'post_date' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $post['post_date'], false )),486 'post_date_gmt' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $post['post_date_gmt'], false )),487 'post_modified' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $post['post_modified'], false )),488 'post_modified_gmt' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $post['post_modified_gmt'], false )),500 'post_date' => $this->_convert_date( $post['post_date'] ), 501 'post_date_gmt' => $this->_convert_date( $post['post_date_gmt'] ), 502 'post_modified' => $this->_convert_date( $post['post_modified'] ), 503 'post_modified_gmt' => $this->_convert_date( $post['post_modified_gmt'] ), 489 504 'post_status' => $post['post_status'], 490 505 'post_type' => $post['post_type'], 491 506 'post_name' => $post['post_name'], … … 880 895 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 881 896 882 897 // convert the date field back to IXR form 883 $post['post_date'] = new IXR_Date( mysql2date( 'Ymd\TH:i:s', $post['post_date'], false ));898 $post['post_date'] = $this->_convert_date( $post['post_date'] ); 884 899 885 900 // ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct, 886 901 // since _insert_post will ignore the non-GMT date if the GMT date is set 887 902 if ( $post['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) 888 903 unset( $post['post_date_gmt'] ); 889 904 else 890 $post['post_date_gmt'] = new IXR_Date( mysql2date( 'Ymd\TH:i:s', $post['post_date_gmt'], false ));905 $post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] ); 891 906 892 907 $this->escape( $post ); 893 908 $merged_content_struct = array_merge( $post, $content_struct );