Ticket #35053: 35053.patch
File 35053.patch, 4.7 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-xmlrpc-server.php
4984 4984 } 4985 4985 4986 4986 // Do some timestamp voodoo 4987 if ( !empty( $content_struct['date_created_gmt'] ) ) 4987 if ( !empty( $content_struct['date_created_gmt'] ) ) { 4988 4988 // We know this is supposed to be GMT, so we're going to slap that Z on there by force 4989 $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; 4990 elseif ( !empty( $content_struct['dateCreated']) ) 4991 $dateCreated = $content_struct['dateCreated']->getIso(); 4989 $dateCreated = iso8601_to_datetime( rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z' ); 4990 $dateCreated = get_date_from_gmt( $dateCreated ); 4991 } elseif ( !empty( $content_struct['dateCreated']) ) { 4992 $dateCreated = iso8601_to_datetime( $content_struct['dateCreated']->getIso() ); 4993 } 4992 4994 4993 4995 if ( !empty( $dateCreated ) ) { 4994 $post_date = iso8601_to_datetime( $dateCreated );4996 $post_date = $dateCreated; 4995 4997 $post_date_gmt = get_gmt_from_date( $post_date ); 4996 4998 } else { 4997 4999 $post_date = ''; … … 5337 5339 $to_ping = implode(' ', $to_ping); 5338 5340 } 5339 5341 5340 // Do some timestamp voodoo. 5341 if ( !empty( $content_struct['date_created_gmt'] ) ) 5342 // We know this is supposed to be GMT, so we're going to slap that Z on there by force. 5343 $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; 5344 elseif ( !empty( $content_struct['dateCreated']) ) 5345 $dateCreated = $content_struct['dateCreated']->getIso(); 5342 // Do some timestamp voodoo 5343 if ( !empty( $content_struct['date_created_gmt'] ) ) { 5344 // We know this is supposed to be GMT, so we're going to slap that Z on there by force 5345 $dateCreated = iso8601_to_datetime( rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z' ); 5346 $dateCreated = get_date_from_gmt( $dateCreated ); 5347 } elseif ( !empty( $content_struct['dateCreated']) ) { 5348 $dateCreated = iso8601_to_datetime( $content_struct['dateCreated']->getIso() ); 5349 } 5346 5350 5347 5351 if ( !empty( $dateCreated ) ) { 5348 $post_date = iso8601_to_datetime( $dateCreated );5352 $post_date = $dateCreated; 5349 5353 $post_date_gmt = get_gmt_from_date( $post_date, 'GMT' ); 5350 5354 } else { 5351 5355 $post_date = $postdata['post_date']; -
tests/phpunit/tests/xmlrpc/mw/editPost.php
246 246 } 247 247 248 248 /** 249 * @ticket 250 */ 251 function test_post_date_gmt_timezone_conversion() { 252 $tz = get_option( 'timezone_string' ); 253 update_option( 'timezone_string', 'America/New_York' ); 254 255 $editor_id = $this->make_user_by_role( 'editor' ); 256 257 $post_id = self::factory()->post->create( array( 258 'post_author' => $editor_id 259 ) ); 260 261 $date_string = '1984-01-11 05:00:00'; 262 // America/New_York's time zone is -5:00 so add 5 hours 263 $date_string_gmt = '1984-01-11 10:00:00'; 264 265 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 266 'date_created_gmt' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string_gmt, false ) ), 267 ) ) ); 268 269 $fetched_post = get_post( $post_id ); 270 271 update_option( 'timezone_string', $tz ); 272 273 $this->assertTrue( $result ); 274 $this->assertEquals( $date_string, $fetched_post->post_date ); 275 } 276 277 /** 249 278 * @ticket 16980 250 279 */ 251 280 function test_empty_not_null() { -
tests/phpunit/tests/xmlrpc/mw/newPost.php
193 193 $this->assertStringMatchesFormat( '%d', $result ); 194 194 $this->assertEquals( $date_string , $fetched_post->post_date ); 195 195 } 196 197 /** 198 * @ticket 199 */ 200 function test_post_date_gmt_timezone_conversion() { 201 $tz = get_option( 'timezone_string' ); 202 update_option( 'timezone_string', 'America/New_York' ); 203 204 $this->make_user_by_role( 'editor' ); 205 $date_string = '1984-01-11 05:00:00'; 206 // America/New_York's time zone is -5:00 so add 5 hours 207 $date_string_gmt = '1984-01-11 10:00:00'; 208 $post = array( 209 'title' => 'test', 210 'post_content' => 'test', 211 'date_created_gmt' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string_gmt, false ) ) 212 ); 213 $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); 214 $fetched_post = get_post( $result ); 215 216 update_option( 'timezone_string', $tz ); 217 218 $this->assertStringMatchesFormat( '%d', $result ); 219 $this->assertEquals( $date_string , $fetched_post->post_date ); 220 } 221 196 222 }