Ticket #19733: patch-core-19733-3.diff
| File patch-core-19733-3.diff, 12.4 KB (added by markoheijnen, 15 months ago) |
|---|
-
wp-includes/class-wp-xmlrpc-server.php
499 499 * Prepares taxonomy data for return in an XML-RPC object. 500 500 * 501 501 * @access protected 502 .*502 * 503 503 * @param array|object $taxonomy The unprepared taxonomy data 504 504 * @return array The prepared taxonomy data 505 505 */ … … 515 515 * Prepares term data for return in an XML-RPC object. 516 516 * 517 517 * @access protected 518 .*518 * 519 519 * @param array|object $term The unprepared term data 520 520 * @return array The prepared term data 521 521 */ … … 552 552 } 553 553 554 554 /** 555 * Convert a WordPress gmt date string to an IXR_Date object. 556 * 557 * @access protected 558 * 559 * @param $date 560 * @return IXR_Date 561 */ 562 protected function _convert_date_gmt( $date_gmt, $date ) { 563 if ( $date === '0000-00-00 00:00:00' ) { 564 return new IXR_Date( '00000000T00:00:00Z' ); 565 } 566 if ( $date_gmt === '0000-00-00 00:00:00' ) { 567 return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) ); 568 } 569 return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_gmt, false ) ); 570 } 571 572 /** 555 573 * Prepares post data for return in an XML-RPC object. 556 574 * 557 575 * @access protected … … 568 586 $post_fields = array( 569 587 'post_title' => $post['post_title'], 570 588 'post_date' => $this->_convert_date( $post['post_date'] ), 571 'post_date_gmt' => $this->_convert_date ( $post['post_date_gmt'] ),589 'post_date_gmt' => $this->_convert_date_gmt( $post['post_date_gmt'], $post['post_date'] ), 572 590 'post_modified' => $this->_convert_date( $post['post_modified'] ), 573 'post_modified_gmt' => $this->_convert_date ( $post['post_modified_gmt'] ),591 'post_modified_gmt' => $this->_convert_date_gmt( $post['post_modified_gmt'], $post['post_modified'] ), 574 592 'post_status' => $post['post_status'], 575 593 'post_type' => $post['post_type'], 576 594 'post_name' => $post['post_name'], … … 1714 1732 $allow_pings = pings_open($page->ID) ? 1 : 0; 1715 1733 1716 1734 // Format page date. 1717 $page_date = mysql2date('Ymd\TH:i:s', $page->post_date, false);1718 $page_date_gmt = mysql2date('Ymd\TH:i:s', $page->post_date_gmt, false);1735 $page_date = $this->_convert_date( $page->post_date ); 1736 $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date ); 1719 1737 1720 // For drafts use the GMT version of the date1721 if ( $page->post_status == 'draft' )1722 $page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' );1723 1724 1738 // Pull the categories info together. 1725 1739 $categories = array(); 1726 1740 foreach ( wp_get_post_categories($page->ID) as $cat_id ) { … … 1735 1749 $page_template = 'default'; 1736 1750 1737 1751 $page_struct = array( 1738 'dateCreated' => new IXR_Date($page_date),1752 'dateCreated' => $page_date, 1739 1753 'userid' => $page->post_author, 1740 1754 'page_id' => $page->ID, 1741 1755 'page_status' => $page->post_status, … … 1756 1770 'wp_page_order' => $page->menu_order, 1757 1771 'wp_author_id' => (string) $author->ID, 1758 1772 'wp_author_display_name' => $author->display_name, 1759 'date_created_gmt' => new IXR_Date($page_date_gmt),1773 'date_created_gmt' => $page_date_gmt, 1760 1774 'custom_fields' => $this->get_custom_fields($page_id), 1761 1775 'wp_page_template' => $page_template 1762 1776 ); … … 1975 1989 // The date needs to be formatted properly. 1976 1990 $num_pages = count($page_list); 1977 1991 for ( $i = 0; $i < $num_pages; $i++ ) { 1978 $p ost_date = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date, false);1979 $p ost_date_gmt = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date_gmt, false);1992 $page_list[$i]->dateCreated = $this->_convert_date( $page_list[$i]->post_date ); 1993 $page_list[$i]->date_created_gmt = $this->_convert_date_gmt( $page_list[$i]->post_date_gmt, $page_list[$i]->post_date ); 1980 1994 1981 $page_list[$i]->dateCreated = new IXR_Date($post_date);1982 $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);1983 1984 // For drafts use the GMT version of the date1985 if ( $page_list[$i]->post_status == 'draft' ) {1986 $page_list[$i]->date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]->post_date ), 'Ymd\TH:i:s' );1987 $page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt );1988 }1989 1990 1995 unset($page_list[$i]->post_date_gmt); 1991 1996 unset($page_list[$i]->post_date); 1992 1997 unset($page_list[$i]->post_status); … … 2230 2235 return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); 2231 2236 2232 2237 // Format page date. 2233 $comment_date = mysql2date('Ymd\TH:i:s', $comment->comment_date, false);2234 $comment_date_gmt = mysql2date('Ymd\TH:i:s', $comment->comment_date_gmt, false);2238 $comment_date = $this->_convert_date( $comment->comment_date ); 2239 $comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date ); 2235 2240 2236 2241 if ( '0' == $comment->comment_approved ) 2237 2242 $comment_status = 'hold'; … … 2245 2250 $link = get_comment_link($comment); 2246 2251 2247 2252 $comment_struct = array( 2248 'date_created_gmt' => new IXR_Date($comment_date_gmt),2253 'date_created_gmt' => $comment_date_gmt, 2249 2254 'user_id' => $comment->user_id, 2250 2255 'comment_id' => $comment->comment_ID, 2251 2256 'parent' => $comment->comment_parent, … … 2824 2829 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 2825 2830 2826 2831 // Format page date. 2827 $attachment_date = mysql2date('Ymd\TH:i:s', $attachment->post_date, false);2828 $attachment_date_gmt = mysql2date('Ymd\TH:i:s', $attachment->post_date_gmt, false);2832 $attachment_date = $this->_convert_date( $attachment->post_date ); 2833 $attachment_date_gmt = $this->_convert_date_gmt( $attachment->post_date_gmt, $attachment->post_date ); 2829 2834 2830 2835 $link = wp_get_attachment_url($attachment->ID); 2831 2836 $thumbnail_link = wp_get_attachment_thumb_url($attachment->ID); 2832 2837 2833 2838 $attachment_struct = array( 2834 'date_created_gmt' => new IXR_Date($attachment_date_gmt),2839 'date_created_gmt' => $attachment_date_gmt, 2835 2840 'parent' => $attachment->post_parent, 2836 2841 'link' => $link, 2837 2842 'thumbnail' => $thumbnail_link, … … 3182 3187 3183 3188 $struct = array( 3184 3189 'userid' => $post_data['post_author'], 3185 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)),3190 'dateCreated' => $this->_convert_date( $post_data['post_date'] ), 3186 3191 'content' => $content, 3187 3192 'postid' => (string) $post_data['ID'] 3188 3193 ); … … 3227 3232 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 3228 3233 continue; 3229 3234 3230 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);3235 $post_date = $this->_convert_date( $entry['post_date'] ); 3231 3236 $categories = implode(',', wp_get_post_categories($entry['ID'])); 3232 3237 3233 3238 $content = '<title>'.stripslashes($entry['post_title']).'</title>'; … … 3236 3241 3237 3242 $struct[] = array( 3238 3243 'userid' => $entry['post_author'], 3239 'dateCreated' => new IXR_Date($post_date),3244 'dateCreated' => $post_date, 3240 3245 'content' => $content, 3241 3246 'postid' => (string) $entry['ID'], 3242 3247 ); … … 4120 4125 $postdata = wp_get_single_post($post_ID, ARRAY_A); 4121 4126 4122 4127 if ($postdata['post_date'] != '') { 4123 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false);4124 $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false);4125 $post_modified = mysql2date('Ymd\TH:i:s', $postdata['post_modified'], false);4126 $post_modified_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_modified_gmt'], false);4128 $post_date = $this->_convert_date( $postdata['post_date'] ); 4129 $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); 4130 $post_modified = $this->_convert_date( $postdata['post_modified'] ); 4131 $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); 4127 4132 4128 // For drafts use the GMT version of the post date4129 if ( $postdata['post_status'] == 'draft' ) {4130 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' );4131 $post_modified_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_modified'] ), 'Ymd\TH:i:s' );4132 }4133 4134 4133 $categories = array(); 4135 4134 $catids = wp_get_post_categories($post_ID); 4136 4135 foreach($catids as $catid) … … 4182 4181 } 4183 4182 4184 4183 $resp = array( 4185 'dateCreated' => new IXR_Date($post_date),4184 'dateCreated' => $post_date, 4186 4185 'userid' => $postdata['post_author'], 4187 4186 'postid' => $postdata['ID'], 4188 4187 'description' => $post['main'], … … 4201 4200 'wp_slug' => $postdata['post_name'], 4202 4201 'wp_password' => $postdata['post_password'], 4203 4202 'wp_author_id' => (string) $author->ID, 4204 'wp_author_display_name' => $author->display_name,4205 'date_created_gmt' => new IXR_Date($post_date_gmt),4203 'wp_author_display_name' => $author->display_name, 4204 'date_created_gmt' => $post_date_gmt, 4206 4205 'post_status' => $postdata['post_status'], 4207 4206 'custom_fields' => $this->get_custom_fields($post_ID), 4208 4207 'wp_post_format' => $post_format, 4209 4208 'sticky' => $sticky, 4210 'date_modified' => new IXR_Date( $post_modified ),4211 'date_modified_gmt' => new IXR_Date( $post_modified_gmt )4209 'date_modified' => $post_modified, 4210 'date_modified_gmt' => $post_modified_gmt 4212 4211 ); 4213 4212 4214 4213 if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; … … 4256 4255 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 4257 4256 continue; 4258 4257 4259 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);4260 $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);4261 $post_modified = mysql2date('Ymd\TH:i:s', $entry['post_modified'], false);4262 $post_modified_gmt = mysql2date('Ymd\TH:i:s', $entry['post_modified_gmt'], false);4258 $post_date = $this->_convert_date( $entry['post_date'] ); 4259 $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); 4260 $post_modified = $this->_convert_date( $entry['post_modified'] ); 4261 $post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified_gmt'], $entry['post_modified'] ); 4263 4262 4264 // For drafts use the GMT version of the date4265 if ( $entry['post_status'] == 'draft' ) {4266 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );4267 $post_modified_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_modified'] ), 'Ymd\TH:i:s' );4268 }4269 4270 4263 $categories = array(); 4271 4264 $catids = wp_get_post_categories($entry['ID']); 4272 4265 foreach( $catids as $catid ) … … 4302 4295 $post_format = 'standard'; 4303 4296 4304 4297 $struct[] = array( 4305 'dateCreated' => new IXR_Date($post_date),4298 'dateCreated' => $post_date, 4306 4299 'userid' => $entry['post_author'], 4307 4300 'postid' => (string) $entry['ID'], 4308 4301 'description' => $post['main'], … … 4322 4315 'wp_password' => $entry['post_password'], 4323 4316 'wp_author_id' => (string) $author->ID, 4324 4317 'wp_author_display_name' => $author->display_name, 4325 'date_created_gmt' => new IXR_Date($post_date_gmt),4318 'date_created_gmt' => $post_date_gmt, 4326 4319 'post_status' => $entry['post_status'], 4327 4320 'custom_fields' => $this->get_custom_fields($entry['ID']), 4328 4321 'wp_post_format' => $post_format, 4329 'date_modified' => new IXR_Date( $post_modified ),4330 'date_modified_gmt' => new IXR_Date( $post_modified_gmt )4322 'date_modified' => $post_modified, 4323 'date_modified_gmt' => $post_modified_gmt 4331 4324 ); 4332 4325 4333 4326 $entry_index = count( $struct ) - 1; … … 4513 4506 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 4514 4507 continue; 4515 4508 4516 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);4517 $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);4509 $post_date = $this->_convert_date( $entry['post_date'] ); 4510 $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); 4518 4511 4519 // For drafts use the GMT version of the date4520 if ( $entry['post_status'] == 'draft' )4521 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );4522 4523 4512 $struct[] = array( 4524 'dateCreated' => new IXR_Date($post_date),4513 'dateCreated' => $post_date, 4525 4514 'userid' => $entry['post_author'], 4526 4515 'postid' => (string) $entry['ID'], 4527 4516 'title' => $entry['post_title'], 4528 4517 'post_status' => $entry['post_status'], 4529 'date_created_gmt' => new IXR_Date($post_date_gmt)4518 'date_created_gmt' => $post_date_gmt 4530 4519 ); 4531 4520 4532 4521 }