Make WordPress Core

Ticket #40136: 40136.diff

File 40136.diff, 2.0 KB (added by nerrad, 7 years ago)

change how gmt is shimmed and revert test back to original state

  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index 7e3e5636c4..36343020e9 100644
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    13991399                        // #38883).  In this case, shim the value based on the `post_date`
    14001400                        // field with the site's timezone offset applied.
    14011401                        if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
    1402                                 $post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) );
     1402                                $post_date_gmt = get_gmt_from_date($post->post_date);
    14031403                        } else {
    14041404                                $post_date_gmt = $post->post_date_gmt;
    14051405                        }
  • tests/phpunit/tests/rest-api/rest-posts-controller.php

    diff --git tests/phpunit/tests/rest-api/rest-posts-controller.php tests/phpunit/tests/rest-api/rest-posts-controller.php
    index abc30d40ce..fb45230daf 100644
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    22372237
    22382238                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    22392239        }
    2240 
     2240       
     2241        /**
     2242         * @group 40284
     2243         */
    22412244        public function test_empty_post_date_gmt_shimmed_using_post_date() {
    22422245                global $wpdb;
    22432246
    22442247                wp_set_current_user( self::$editor_id );
    2245                 update_option( 'timezone_string', '' );
    2246                 update_option( 'gmt_offset', -6 );
     2248                update_option( 'timezone_string', 'America/Chicago' );
    22472249
    22482250                // Need to set dates using wpdb directly because `wp_update_post` and
    22492251                // `wp_insert_post` have additional validation on dates.
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    22882290                $this->assertEquals( $post->post_date_gmt, '2016-02-23 19:00:00' );
    22892291
    22902292                update_option( 'timezone_string', '' );
    2291                 update_option( 'gmt_offset', 0 );
    22922293        }
    22932294
    22942295        public function test_update_post_slug() {