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/newPost.php

    r34572 r34681  
    181181                $this->assertEquals( '0000-00-00 00:00:00', $out->post_date_gmt );
    182182        }
     183
     184        /**
     185         * @ticket 30429
     186         */
     187        function test_post_date_timezone_conversion() {
     188                $tz = get_option( 'timezone_string' );
     189                update_option( 'timezone_string', 'America/New_York' );
     190
     191                $this->make_user_by_role( 'editor' );
     192                $date_string = '1984-01-11 05:00:00';
     193                $post = array(
     194                        'title' => 'test',
     195                        'post_content' => 'test',
     196                        'dateCreated' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) )
     197                );
     198                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
     199                $fetched_post = get_post( $result );
     200
     201                update_option( 'timezone_string', $tz );
     202
     203                $this->assertStringMatchesFormat( '%d', $result );
     204                $this->assertEquals( $date_string , $fetched_post->post_date );
     205        }
    183206}
Note: See TracChangeset for help on using the changeset viewer.