Ticket #19733: patch-core-19733-4.2.diff
| File patch-core-19733-4.2.diff, 12.8 KB (added by markoheijnen, 14 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 */ … … 548 548 if ( $date === '0000-00-00 00:00:00' ) { 549 549 return new IXR_Date( '00000000T00:00:00Z' ); 550 550 } 551 return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );551 return new IXR_Date( $this->_convert_mysql2date( $date ) ); 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' && $date_gmt === '0000-00-00 00:00:00' ) { 564 return new IXR_Date( get_gmt_from_date( $this->_convert_mysql2date( $date, 'Y-m-d H:i:s' ), 'Ymd\TH:i:s' ) ); 565 } 566 return $this-> _convert_date( $date_gmt ); 567 } 568 569 /** 570 * Convert a MySQL date to 571 * 572 * @access protected 573 * 574 * @param $date 575 * @return IXR_Date 576 */ 577 protected function _convert_mysql2date( $date, $format = 'Ymd\TH:i:s' ) { 578 return mysql2date( $format, $date, false ); 579 } 580 581 /** 555 582 * Prepares post data for return in an XML-RPC object. 556 583 * 557 584 * @access protected … … 568 595 $post_fields = array( 569 596 'post_title' => $post['post_title'], 570 597 'post_date' => $this->_convert_date( $post['post_date'] ), 571 'post_date_gmt' => $this->_convert_date ( $post['post_date_gmt'] ),598 'post_date_gmt' => $this->_convert_date_gmt( $post['post_date_gmt'], $post['post_date'] ), 572 599 'post_modified' => $this->_convert_date( $post['post_modified'] ), 573 'post_modified_gmt' => $this->_convert_date ( $post['post_modified_gmt'] ),600 'post_modified_gmt' => $this->_convert_date_gmt( $post['post_modified_gmt'], $post['post_modified'] ), 574 601 'post_status' => $post['post_status'], 575 602 'post_type' => $post['post_type'], 576 603 'post_name' => $post['post_name'], … … 1714 1741 $allow_pings = pings_open($page->ID) ? 1 : 0; 1715 1742 1716 1743 // 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);1744 $page_date = $this->_convert_date( $page->post_date ); 1745 $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date ); 1719 1746 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 1747 // Pull the categories info together. 1725 1748 $categories = array(); 1726 1749 foreach ( wp_get_post_categories($page->ID) as $cat_id ) { … … 1735 1758 $page_template = 'default'; 1736 1759 1737 1760 $page_struct = array( 1738 'dateCreated' => new IXR_Date($page_date),1761 'dateCreated' => $page_date, 1739 1762 'userid' => $page->post_author, 1740 1763 'page_id' => $page->ID, 1741 1764 'page_status' => $page->post_status, … … 1756 1779 'wp_page_order' => $page->menu_order, 1757 1780 'wp_author_id' => (string) $author->ID, 1758 1781 'wp_author_display_name' => $author->display_name, 1759 'date_created_gmt' => new IXR_Date($page_date_gmt),1782 'date_created_gmt' => $page_date_gmt, 1760 1783 'custom_fields' => $this->get_custom_fields($page_id), 1761 1784 'wp_page_template' => $page_template 1762 1785 ); … … 1975 1998 // The date needs to be formatted properly. 1976 1999 $num_pages = count($page_list); 1977 2000 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);2001 $page_list[$i]->dateCreated = $this->_convert_date( $page_list[$i]->post_date ); 2002 $page_list[$i]->date_created_gmt = $this->_convert_date_gmt( $page_list[$i]->post_date_gmt, $page_list[$i]->post_date ); 1980 2003 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 2004 unset($page_list[$i]->post_date_gmt); 1991 2005 unset($page_list[$i]->post_date); 1992 2006 unset($page_list[$i]->post_status); … … 2230 2244 return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); 2231 2245 2232 2246 // 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);2247 $comment_date = $this->_convert_date( $comment->comment_date ); 2248 $comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date ); 2235 2249 2236 2250 if ( '0' == $comment->comment_approved ) 2237 2251 $comment_status = 'hold'; … … 2245 2259 $link = get_comment_link($comment); 2246 2260 2247 2261 $comment_struct = array( 2248 'date_created_gmt' => new IXR_Date($comment_date_gmt),2262 'date_created_gmt' => $comment_date_gmt, 2249 2263 'user_id' => $comment->user_id, 2250 2264 'comment_id' => $comment->comment_ID, 2251 2265 'parent' => $comment->comment_parent, … … 2824 2838 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 2825 2839 2826 2840 // 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);2841 $attachment_date = $this->_convert_date( $attachment->post_date ); 2842 $attachment_date_gmt = $this->_convert_date_gmt( $attachment->post_date_gmt, $attachment->post_date ); 2829 2843 2830 2844 $link = wp_get_attachment_url($attachment->ID); 2831 2845 $thumbnail_link = wp_get_attachment_thumb_url($attachment->ID); 2832 2846 2833 2847 $attachment_struct = array( 2834 'date_created_gmt' => new IXR_Date($attachment_date_gmt),2848 'date_created_gmt' => $attachment_date_gmt, 2835 2849 'parent' => $attachment->post_parent, 2836 2850 'link' => $link, 2837 2851 'thumbnail' => $thumbnail_link, … … 3182 3196 3183 3197 $struct = array( 3184 3198 'userid' => $post_data['post_author'], 3185 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)),3199 'dateCreated' => $this->_convert_date( $post_data['post_date'] ), 3186 3200 'content' => $content, 3187 3201 'postid' => (string) $post_data['ID'] 3188 3202 ); … … 3227 3241 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 3228 3242 continue; 3229 3243 3230 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);3244 $post_date = $this->_convert_date( $entry['post_date'] ); 3231 3245 $categories = implode(',', wp_get_post_categories($entry['ID'])); 3232 3246 3233 3247 $content = '<title>'.stripslashes($entry['post_title']).'</title>'; … … 3236 3250 3237 3251 $struct[] = array( 3238 3252 'userid' => $entry['post_author'], 3239 'dateCreated' => new IXR_Date($post_date),3253 'dateCreated' => $post_date, 3240 3254 'content' => $content, 3241 3255 'postid' => (string) $entry['ID'], 3242 3256 ); … … 4120 4134 $postdata = wp_get_single_post($post_ID, ARRAY_A); 4121 4135 4122 4136 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);4137 $post_date = $this->_convert_date( $postdata['post_date'] ); 4138 $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); 4139 $post_modified = $this->_convert_date( $postdata['post_modified'] ); 4140 $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); 4127 4141 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 4142 $categories = array(); 4135 4143 $catids = wp_get_post_categories($post_ID); 4136 4144 foreach($catids as $catid) … … 4182 4190 } 4183 4191 4184 4192 $resp = array( 4185 'dateCreated' => new IXR_Date($post_date),4193 'dateCreated' => $post_date, 4186 4194 'userid' => $postdata['post_author'], 4187 4195 'postid' => $postdata['ID'], 4188 4196 'description' => $post['main'], … … 4201 4209 'wp_slug' => $postdata['post_name'], 4202 4210 'wp_password' => $postdata['post_password'], 4203 4211 'wp_author_id' => (string) $author->ID, 4204 'wp_author_display_name' => $author->display_name,4205 'date_created_gmt' => new IXR_Date($post_date_gmt),4212 'wp_author_display_name' => $author->display_name, 4213 'date_created_gmt' => $post_date_gmt, 4206 4214 'post_status' => $postdata['post_status'], 4207 4215 'custom_fields' => $this->get_custom_fields($post_ID), 4208 4216 'wp_post_format' => $post_format, 4209 4217 'sticky' => $sticky, 4210 'date_modified' => new IXR_Date( $post_modified ),4211 'date_modified_gmt' => new IXR_Date( $post_modified_gmt )4218 'date_modified' => $post_modified, 4219 'date_modified_gmt' => $post_modified_gmt 4212 4220 ); 4213 4221 4214 4222 if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; … … 4256 4264 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 4257 4265 continue; 4258 4266 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);4267 $post_date = $this->_convert_date( $entry['post_date'] ); 4268 $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); 4269 $post_modified = $this->_convert_date( $entry['post_modified'] ); 4270 $post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified_gmt'], $entry['post_modified'] ); 4263 4271 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 4272 $categories = array(); 4271 4273 $catids = wp_get_post_categories($entry['ID']); 4272 4274 foreach( $catids as $catid ) … … 4302 4304 $post_format = 'standard'; 4303 4305 4304 4306 $struct[] = array( 4305 'dateCreated' => new IXR_Date($post_date),4307 'dateCreated' => $post_date, 4306 4308 'userid' => $entry['post_author'], 4307 4309 'postid' => (string) $entry['ID'], 4308 4310 'description' => $post['main'], … … 4322 4324 'wp_password' => $entry['post_password'], 4323 4325 'wp_author_id' => (string) $author->ID, 4324 4326 'wp_author_display_name' => $author->display_name, 4325 'date_created_gmt' => new IXR_Date($post_date_gmt),4327 'date_created_gmt' => $post_date_gmt, 4326 4328 'post_status' => $entry['post_status'], 4327 4329 'custom_fields' => $this->get_custom_fields($entry['ID']), 4328 4330 'wp_post_format' => $post_format, 4329 'date_modified' => new IXR_Date( $post_modified ),4330 'date_modified_gmt' => new IXR_Date( $post_modified_gmt )4331 'date_modified' => $post_modified, 4332 'date_modified_gmt' => $post_modified_gmt 4331 4333 ); 4332 4334 4333 4335 $entry_index = count( $struct ) - 1; … … 4513 4515 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 4514 4516 continue; 4515 4517 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);4518 $post_date = $this->_convert_date( $entry['post_date'] ); 4519 $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); 4518 4520 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 4521 $struct[] = array( 4524 'dateCreated' => new IXR_Date($post_date),4522 'dateCreated' => $post_date, 4525 4523 'userid' => $entry['post_author'], 4526 4524 'postid' => (string) $entry['ID'], 4527 4525 'title' => $entry['post_title'], 4528 4526 'post_status' => $entry['post_status'], 4529 'date_created_gmt' => new IXR_Date($post_date_gmt)4527 'date_created_gmt' => $post_date_gmt 4530 4528 ); 4531 4529 4532 4530 }
