Make WordPress Core

Changeset 36164


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

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

Merges [36163] to the 4.4 branch.

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

Location:
branches/4.4
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/src/wp-includes/class-wp-xmlrpc-server.php

    r35479 r36164  
    13501350
    13511351        if ( ! empty( $dateCreated ) ) {
    1352             $post_data['post_date'] = iso8601_to_datetime( $dateCreated );
    1353             $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
     1352            $post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
     1353            $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' );
    13541354        }
    13551355
     
    34243424            // We know this is supposed to be GMT, so we're going to slap that Z on there by force
    34253425            $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
    3426             $comment_date = iso8601_to_datetime( $dateCreated );
    3427             $comment_date_gmt = get_gmt_from_date( $comment_date );
     3426            $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
     3427            $comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
    34283428        }
    34293429
     
    49924992
    49934993        if ( !empty( $dateCreated ) ) {
    4994             $post_date = iso8601_to_datetime( $dateCreated );
    4995             $post_date_gmt = get_gmt_from_date( $post_date );
     4994            $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
     4995            $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
    49964996        } else {
    49974997            $post_date = '';
     
    53465346
    53475347        if ( !empty( $dateCreated ) ) {
    5348             $post_date = iso8601_to_datetime( $dateCreated );
    5349             $post_date_gmt = get_gmt_from_date( $post_date, 'GMT' );
     5348            $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
     5349            $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
    53505350        } else {
    53515351            $post_date     = $postdata['post_date'];
  • branches/4.4/tests/phpunit/tests/xmlrpc/mw/editPost.php

    r35242 r36164  
    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     */
  • branches/4.4/tests/phpunit/tests/xmlrpc/mw/newPost.php

    r35242 r36164  
    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}
  • branches/4.4/tests/phpunit/tests/xmlrpc/wp/editComment.php

    r35242 r36164  
    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}
  • branches/4.4/tests/phpunit/tests/xmlrpc/wp/newPost.php

    r35242 r36164  
    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.