Make WordPress Core


Ignore:
Timestamp:
05/26/2019 12:11:37 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Date/Time: Replace all instances of date() with gmdate().

Use of date() in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

gmdate() is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/url.php

    r42343 r45424  
    337337    public function test_get_adjacent_post() {
    338338        $now      = time();
    339         $post_id  = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    340         $post_id2 = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     339        $post_id  = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ) ) );
     340        $post_id2 = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now ) ) );
    341341
    342342        if ( ! isset( $GLOBALS['post'] ) ) {
     
    380380                'post_author' => $u,
    381381                'post_status' => 'private',
    382                 'post_date'   => date( 'Y-m-d H:i:s', $now - 1 ),
     382                'post_date'   => gmdate( 'Y-m-d H:i:s', $now - 1 ),
    383383            )
    384384        );
     
    386386            array(
    387387                'post_author' => $u,
    388                 'post_date'   => date( 'Y-m-d H:i:s', $now ),
     388                'post_date'   => gmdate( 'Y-m-d H:i:s', $now ),
    389389            )
    390390        );
     
    418418                'post_author' => $u1,
    419419                'post_status' => 'private',
    420                 'post_date'   => date( 'Y-m-d H:i:s', $now - 1 ),
     420                'post_date'   => gmdate( 'Y-m-d H:i:s', $now - 1 ),
    421421            )
    422422        );
     
    424424            array(
    425425                'post_author' => $u1,
    426                 'post_date'   => date( 'Y-m-d H:i:s', $now ),
     426                'post_date'   => gmdate( 'Y-m-d H:i:s', $now ),
    427427            )
    428428        );
     
    455455            array(
    456456                'post_author' => $u1,
    457                 'post_date'   => date( 'Y-m-d H:i:s', $now - 2 ),
     457                'post_date'   => gmdate( 'Y-m-d H:i:s', $now - 2 ),
    458458            )
    459459        );
     
    462462                'post_author' => $u1,
    463463                'post_status' => 'private',
    464                 'post_date'   => date( 'Y-m-d H:i:s', $now - 1 ),
     464                'post_date'   => gmdate( 'Y-m-d H:i:s', $now - 1 ),
    465465            )
    466466        );
     
    468468            array(
    469469                'post_author' => $u1,
    470                 'post_date'   => date( 'Y-m-d H:i:s', $now ),
     470                'post_date'   => gmdate( 'Y-m-d H:i:s', $now ),
    471471            )
    472472        );
Note: See TracChangeset for help on using the changeset viewer.