Ticket #19733: patch-core-19733-2.diff
| File patch-core-19733-2.diff, 11.8 KB (added by , 14 years ago) |
|---|
-
wp-includes/class-wp-xmlrpc-server.php
492 492 * Prepares taxonomy data for return in an XML-RPC object. 493 493 * 494 494 * @access protected 495 .*495 * 496 496 * @param array|object $taxonomy The unprepared taxonomy data 497 497 * @return array The prepared taxonomy data 498 498 */ … … 508 508 * Prepares term data for return in an XML-RPC object. 509 509 * 510 510 * @access protected 511 .*511 * 512 512 * @param array|object $term The unprepared term data 513 513 * @return array The prepared term data 514 514 */ … … 537 537 * @param $date 538 538 * @return IXR_Date 539 539 */ 540 protected function _convert_date( $date ) {540 protected function _convert_date( $date, $format = 'Ymd\TH:i:s' ) { 541 541 if ( $date === '0000-00-00 00:00:00' ) { 542 542 return new IXR_Date( '00000000T00:00:00Z' ); 543 543 } 544 return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );544 return new IXR_Date( mysql2date( $format, $date, false ) ); 545 545 } 546 546 547 547 /** 548 * Convert a WordPress gmt date string to an IXR_Date object. 549 * 550 * @access protected 551 * 552 * @param $date 553 * @return IXR_Date 554 */ 555 protected function _convert_date_gmt( $date, $format = 'Ymd\TH:i:s' ) { 556 if ( $date === '0000-00-00 00:00:00' ) { 557 return new IXR_Date( '00000000T00:00:00Z' ); 558 } 559 return new IXR_Date( get_gmt_from_date( mysql2date( $format, $date, false ) ) ); 560 } 561 562 /** 548 563 * Prepares post data for return in an XML-RPC object. 549 564 * 550 565 * @access protected … … 1633 1648 $allow_pings = pings_open($page->ID) ? 1 : 0; 1634 1649 1635 1650 // Format page date. 1636 $page_date = mysql2date('Ymd\TH:i:s', $page->post_date, false);1637 $page_date_gmt = mysql2date('Ymd\TH:i:s', $page->post_date_gmt, false);1651 $page_date = $this->_convert_date( $page->post_date ); 1652 $page_date_gmt = $this->_convert_date( $page->post_date_gmt ); 1638 1653 1639 1654 // For drafts use the GMT version of the date 1640 1655 if ( $page->post_status == 'draft' ) 1641 $page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s');1656 $page_date_gmt = $this->_convert_date_gmt( $page->post_date ); 1642 1657 1643 1658 // Pull the categories info together. 1644 1659 $categories = array(); … … 1654 1669 $page_template = 'default'; 1655 1670 1656 1671 $page_struct = array( 1657 'dateCreated' => new IXR_Date($page_date),1672 'dateCreated' => $page_date, 1658 1673 'userid' => $page->post_author, 1659 1674 'page_id' => $page->ID, 1660 1675 'page_status' => $page->post_status, … … 1675 1690 'wp_page_order' => $page->menu_order, 1676 1691 'wp_author_id' => (string) $author->ID, 1677 1692 'wp_author_display_name' => $author->display_name, 1678 'date_created_gmt' => new IXR_Date($page_date_gmt),1693 'date_created_gmt' => $page_date_gmt, 1679 1694 'custom_fields' => $this->get_custom_fields($page_id), 1680 1695 'wp_page_template' => $page_template 1681 1696 ); … … 1894 1909 // The date needs to be formatted properly. 1895 1910 $num_pages = count($page_list); 1896 1911 for ( $i = 0; $i < $num_pages; $i++ ) { 1897 $p ost_date = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date, false);1898 $p ost_date_gmt = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date_gmt, false);1912 $page_list[$i]->dateCreated = $this->_convert_date( $page_list[$i]->post_date ); 1913 $page_list[$i]->date_created_gmt = $this->_convert_date( $page_list[$i]->post_date_gmt ); 1899 1914 1900 $page_list[$i]->dateCreated = new IXR_Date($post_date);1901 $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);1902 1903 1915 // For drafts use the GMT version of the date 1904 1916 if ( $page_list[$i]->post_status == 'draft' ) { 1905 $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' ); 1906 $page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt ); 1917 $page_list[$i]->date_created_gmt = $this->_convert_date_gmt( $page_list[$i]->post_date ); 1907 1918 } 1908 1919 1909 1920 unset($page_list[$i]->post_date_gmt); … … 2149 2160 return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); 2150 2161 2151 2162 // Format page date. 2152 $comment_date = mysql2date('Ymd\TH:i:s', $comment->comment_date, false);2153 $comment_date_gmt = mysql2date('Ymd\TH:i:s', $comment->comment_date_gmt, false);2163 $comment_date = $this->_convert_date( $comment->comment_date ); 2164 $comment_date_gmt = $this->_convert_date( $comment->comment_date_gmt ); 2154 2165 2155 2166 if ( '0' == $comment->comment_approved ) 2156 2167 $comment_status = 'hold'; … … 2164 2175 $link = get_comment_link($comment); 2165 2176 2166 2177 $comment_struct = array( 2167 'date_created_gmt' => new IXR_Date($comment_date_gmt),2178 'date_created_gmt' => $comment_date_gmt, 2168 2179 'user_id' => $comment->user_id, 2169 2180 'comment_id' => $comment->comment_ID, 2170 2181 'parent' => $comment->comment_parent, … … 2743 2754 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 2744 2755 2745 2756 // Format page date. 2746 $attachment_date = mysql2date('Ymd\TH:i:s', $attachment->post_date, false);2747 $attachment_date_gmt = mysql2date('Ymd\TH:i:s', $attachment->post_date_gmt, false);2757 $attachment_date = $this->_convert_date( $attachment->post_date ); 2758 $attachment_date_gmt = $this->_convert_date( $attachment->post_date_gmt ); 2748 2759 2749 2760 $link = wp_get_attachment_url($attachment->ID); 2750 2761 $thumbnail_link = wp_get_attachment_thumb_url($attachment->ID); 2751 2762 2752 2763 $attachment_struct = array( 2753 'date_created_gmt' => new IXR_Date($attachment_date_gmt),2764 'date_created_gmt' => $attachment_date_gmt, 2754 2765 'parent' => $attachment->post_parent, 2755 2766 'link' => $link, 2756 2767 'thumbnail' => $thumbnail_link, … … 3005 3016 3006 3017 $struct = array( 3007 3018 'userid' => $post_data['post_author'], 3008 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)),3019 'dateCreated' => $this->_convert_date( $post_data['post_date'] ), 3009 3020 'content' => $content, 3010 3021 'postid' => (string) $post_data['ID'] 3011 3022 ); … … 3050 3061 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 3051 3062 continue; 3052 3063 3053 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);3064 $post_date = $this->_convert_date( $entry['post_date'] ); 3054 3065 $categories = implode(',', wp_get_post_categories($entry['ID'])); 3055 3066 3056 3067 $content = '<title>'.stripslashes($entry['post_title']).'</title>'; … … 3059 3070 3060 3071 $struct[] = array( 3061 3072 'userid' => $entry['post_author'], 3062 'dateCreated' => new IXR_Date($post_date),3073 'dateCreated' => $post_date, 3063 3074 'content' => $content, 3064 3075 'postid' => (string) $entry['ID'], 3065 3076 ); … … 3918 3929 $postdata = wp_get_single_post($post_ID, ARRAY_A); 3919 3930 3920 3931 if ($postdata['post_date'] != '') { 3921 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false);3922 $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false);3923 $post_modified = mysql2date('Ymd\TH:i:s', $postdata['post_modified'], false);3924 $post_modified_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_modified_gmt'], false);3932 $post_date = $this->_convert_date( $postdata['post_date'] ); 3933 $post_date_gmt = $this->_convert_date( $postdata['post_date_gmt'] ); 3934 $post_modified = $this->_convert_date( $postdata['post_modified'] ); 3935 $post_modified_gmt = $this->_convert_date( $postdata['post_modified_gmt'] ); 3925 3936 3926 3937 // For drafts use the GMT version of the post date 3927 3938 if ( $postdata['post_status'] == 'draft' ) { 3928 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s');3929 $post_modified_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_modified'] ), 'Ymd\TH:i:s');3939 $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date'] ); 3940 $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified'] ); 3930 3941 } 3931 3942 3932 3943 $categories = array(); … … 3980 3991 } 3981 3992 3982 3993 $resp = array( 3983 'dateCreated' => new IXR_Date($post_date),3994 'dateCreated' => $post_date, 3984 3995 'userid' => $postdata['post_author'], 3985 3996 'postid' => $postdata['ID'], 3986 3997 'description' => $post['main'], … … 3999 4010 'wp_slug' => $postdata['post_name'], 4000 4011 'wp_password' => $postdata['post_password'], 4001 4012 'wp_author_id' => (string) $author->ID, 4002 'wp_author_display_name' => $author->display_name,4003 'date_created_gmt' => new IXR_Date($post_date_gmt),4013 'wp_author_display_name' => $author->display_name, 4014 'date_created_gmt' => $post_date_gmt, 4004 4015 'post_status' => $postdata['post_status'], 4005 4016 'custom_fields' => $this->get_custom_fields($post_ID), 4006 4017 'wp_post_format' => $post_format, 4007 4018 'sticky' => $sticky, 4008 'date_modified' => new IXR_Date( $post_modified ),4009 'date_modified_gmt' => new IXR_Date( $post_modified_gmt )4019 'date_modified' => $post_modified, 4020 'date_modified_gmt' => $post_modified_gmt 4010 4021 ); 4011 4022 4012 4023 if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; … … 4051 4062 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 4052 4063 continue; 4053 4064 4054 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);4055 $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);4056 $post_modified = mysql2date('Ymd\TH:i:s', $entry['post_modified'], false);4057 $post_modified_gmt = mysql2date('Ymd\TH:i:s', $entry['post_modified_gmt'], false);4065 $post_date = $this->_convert_date( $entry['post_date'] ); 4066 $post_date_gmt = $this->_convert_date( $entry['post_date_gmt'] ); 4067 $post_modified = $this->_convert_date( $entry['post_modified'] ); 4068 $post_modified_gmt = $this->_convert_date( $entry['post_modified_gmt'] ); 4058 4069 4059 4070 // For drafts use the GMT version of the date 4060 4071 if ( $entry['post_status'] == 'draft' ) { 4061 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s');4062 $post_modified_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_modified'] ), 'Ymd\TH:i:s');4072 $post_date_gmt = $this->_convert_date_gmt( $entry['post_date'] ); 4073 $post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified'] ); 4063 4074 } 4064 4075 4065 4076 $categories = array(); … … 4097 4108 $post_format = 'standard'; 4098 4109 4099 4110 $struct[] = array( 4100 'dateCreated' => new IXR_Date($post_date),4111 'dateCreated' => $post_date, 4101 4112 'userid' => $entry['post_author'], 4102 4113 'postid' => (string) $entry['ID'], 4103 4114 'description' => $post['main'], … … 4117 4128 'wp_password' => $entry['post_password'], 4118 4129 'wp_author_id' => (string) $author->ID, 4119 4130 'wp_author_display_name' => $author->display_name, 4120 'date_created_gmt' => new IXR_Date($post_date_gmt),4131 'date_created_gmt' => $post_date_gmt, 4121 4132 'post_status' => $entry['post_status'], 4122 4133 'custom_fields' => $this->get_custom_fields($entry['ID']), 4123 4134 'wp_post_format' => $post_format, 4124 'date_modified' => new IXR_Date( $post_modified ),4125 'date_modified_gmt' => new IXR_Date( $post_modified_gmt )4135 'date_modified' => $post_modified, 4136 'date_modified_gmt' => $post_modified_gmt 4126 4137 ); 4127 4138 4128 4139 } … … 4299 4310 if ( !current_user_can( 'edit_post', $entry['ID'] ) ) 4300 4311 continue; 4301 4312 4302 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);4303 $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);4313 $post_date = $this->_convert_date( $entry['post_date'] ); 4314 $post_date_gmt = $this->_convert_date( $entry['post_date_gmt'] ); 4304 4315 4305 4316 // For drafts use the GMT version of the date 4306 4317 if ( $entry['post_status'] == 'draft' ) 4307 $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s');4318 $post_date_gmt = $this->_convert_date_gmt( $entry['post_date'] ); 4308 4319 4309 4320 $struct[] = array( 4310 'dateCreated' => new IXR_Date($post_date),4321 'dateCreated' => $post_date, 4311 4322 'userid' => $entry['post_author'], 4312 4323 'postid' => (string) $entry['ID'], 4313 4324 'title' => $entry['post_title'], 4314 4325 'post_status' => $entry['post_status'], 4315 'date_created_gmt' => new IXR_Date($post_date_gmt)4326 'date_created_gmt' => $post_date_gmt 4316 4327 ); 4317 4328 4318 4329 }