Make WordPress Core


Ignore:
Timestamp:
09/29/2015 04:04:16 AM (11 years ago)
Author:
wonderboymusic
Message:

XML-RPC: calculate the proper offset for GMT in wp.newPost, mw.newPost, and mw.editPost when post_date is set, wp.editComment when comment_date is set. post|comment_date is assumed to be GMT. This is only true if the timezone string for the site matches GMT.

Adds unit tests for each.

Props smerriman, justdaiv, wonderboymusic.
Fixes #30429.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/mw/editPost.php

    r33612 r34681  
    230230                $this->assertEquals( $result->code, 401 );
    231231        }
     232
     233        /**
     234         * @ticket 30429
     235         */
     236        function test_post_date_timezone_conversion() {
     237                $tz = get_option( 'timezone_string' );
     238                update_option( 'timezone_string', 'America/New_York' );
     239
     240                $editor_id = $this->make_user_by_role( 'editor' );
     241
     242                $post_id = $this->factory->post->create( array(
     243                        'post_author' => $editor_id
     244                ) );
     245
     246                $date_string = '1984-01-11 05:00:00';
     247                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array(
     248                        'dateCreated' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) ),
     249                ) ) );
     250
     251                $fetched_post = get_post( $post_id );
     252
     253                update_option( 'timezone_string', $tz );
     254
     255                $this->assertTrue( $result );
     256                $this->assertEquals( $date_string, $fetched_post->post_date );
     257        }
    232258}
Note: See TracChangeset for help on using the changeset viewer.