Make WordPress Core

Changeset 36163


Ignore:
Timestamp:
01/03/2016 07:48:07 PM (9 years ago)
Author:
nacin
Message:

XML-RPC: Revert [34681] as it broke date handling.

props dossy, hnle, redsweater.
see #35053, #30429 (original ticket).

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r35964 r36163  
    13531353
    13541354        if ( ! empty( $dateCreated ) ) {
    1355             $post_data['post_date'] = iso8601_to_datetime( $dateCreated );
    1356             $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
     1355            $post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
     1356            $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' );
    13571357        }
    13581358
     
    34273427            // We know this is supposed to be GMT, so we're going to slap that Z on there by force
    34283428            $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
    3429             $comment_date = iso8601_to_datetime( $dateCreated );
    3430             $comment_date_gmt = get_gmt_from_date( $comment_date );
     3429            $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
     3430            $comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
    34313431        }
    34323432
     
    50065006
    50075007        if ( !empty( $dateCreated ) ) {
    5008             $post_date = iso8601_to_datetime( $dateCreated );
    5009             $post_date_gmt = get_gmt_from_date( $post_date );
     5008            $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
     5009            $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
    50105010        } else {
    50115011            $post_date = '';
     
    53645364
    53655365        if ( !empty( $dateCreated ) ) {
    5366             $post_date = iso8601_to_datetime( $dateCreated );
    5367             $post_date_gmt = get_gmt_from_date( $post_date, 'GMT' );
     5366            $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
     5367            $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
    53685368        } else {
    53695369            $post_date     = $postdata['post_date'];
  • trunk/tests/phpunit/tests/xmlrpc/mw/editPost.php

    r35242 r36163  
    221221
    222222    /**
    223      * @ticket 30429
    224      */
    225     function test_post_date_timezone_conversion() {
    226         $tz = get_option( 'timezone_string' );
    227         update_option( 'timezone_string', 'America/New_York' );
    228 
    229         $editor_id = $this->make_user_by_role( 'editor' );
    230 
    231         $post_id = self::factory()->post->create( array(
    232             'post_author' => $editor_id
    233         ) );
    234 
    235         $date_string = '1984-01-11 05:00:00';
    236         $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array(
    237             'dateCreated' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) ),
    238         ) ) );
    239 
    240         $fetched_post = get_post( $post_id );
    241 
    242         update_option( 'timezone_string', $tz );
    243 
    244         $this->assertTrue( $result );
    245         $this->assertEquals( $date_string, $fetched_post->post_date );
    246     }
    247 
    248     /**
    249223     * @ticket 16980
    250224     */
  • trunk/tests/phpunit/tests/xmlrpc/mw/newPost.php

    r35242 r36163  
    171171        $this->assertEquals( '0000-00-00 00:00:00', $out->post_date_gmt );
    172172    }
    173 
    174     /**
    175      * @ticket 30429
    176      */
    177     function test_post_date_timezone_conversion() {
    178         $tz = get_option( 'timezone_string' );
    179         update_option( 'timezone_string', 'America/New_York' );
    180 
    181         $this->make_user_by_role( 'editor' );
    182         $date_string = '1984-01-11 05:00:00';
    183         $post = array(
    184             'title' => 'test',
    185             'post_content' => 'test',
    186             'dateCreated' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) )
    187         );
    188         $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    189         $fetched_post = get_post( $result );
    190 
    191         update_option( 'timezone_string', $tz );
    192 
    193         $this->assertStringMatchesFormat( '%d', $result );
    194         $this->assertEquals( $date_string , $fetched_post->post_date );
    195     }
    196173}
  • trunk/tests/phpunit/tests/xmlrpc/wp/editComment.php

    r35242 r36163  
    7070        $this->assertEquals( 'trash', get_comment( $comment_id )->comment_approved );
    7171    }
    72 
    73     /**
    74      * @ticket 30429
    75      */
    76     function test_post_date_timezone_conversion() {
    77         $tz = get_option( 'timezone_string' );
    78         update_option( 'timezone_string', 'America/New_York' );
    79 
    80         $this->make_user_by_role( 'administrator' );
    81         $post_id = self::factory()->post->create();
    82 
    83         $comment_data = array(
    84             'comment_post_ID' => $post_id,
    85             'comment_author' => 'Test commenter',
    86             'comment_author_url' => 'http://example.com/',
    87             'comment_author_email' => 'example@example.com',
    88             'comment_content' => rand_str( 100 ),
    89             'comment_approved' => '1',
    90         );
    91         $comment_id = wp_insert_comment( $comment_data );
    92 
    93         $date_string = '1984-01-11 05:00:00';
    94         $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'administrator', 'administrator', $comment_id, array(
    95             'date_created_gmt' => new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date_string, false ) )
    96         ) ) );
    97         $fetched_comment = get_comment( $comment_id );
    98 
    99         update_option( 'timezone_string', $tz );
    100 
    101         $this->assertTrue( $result );
    102         $this->assertEquals( $date_string, $fetched_comment->comment_date );
    103     }
    10472}
  • trunk/tests/phpunit/tests/xmlrpc/wp/newPost.php

    r35242 r36163  
    374374    }
    375375
    376     /**
    377      * @ticket 30429
    378      */
    379     function test_post_date_timezone_conversion() {
    380         $tz = get_option( 'timezone_string' );
    381         update_option( 'timezone_string', 'America/New_York' );
    382 
    383         $this->make_user_by_role( 'author' );
    384         $date_string = '1984-01-11 05:00:00';
    385         $post = array( 'post_title' => 'test', 'post_content' => 'test', 'post_date' => $date_string );
    386         $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    387         $fetched_post = get_post( $result );
    388 
    389         update_option( 'timezone_string', $tz );
    390 
    391         $this->assertStringMatchesFormat( '%d', $result );
    392         $this->assertEquals( $date_string , $fetched_post->post_date );
    393     }
    394376}
Note: See TracChangeset for help on using the changeset viewer.