Make WordPress Core


Ignore:
Timestamp:
05/26/2019 12:11:37 AM (6 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/comment/getPageOfComment.php

    r43571 r45424  
    4646                    'comment_post_ID'  => $p,
    4747                    'comment_type'     => 'trackback',
    48                     'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
     48                    'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
    4949                )
    5050            );
     
    5858                    'comment_post_ID'  => $p,
    5959                    'comment_type'     => 'pingback',
    60                     'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
     60                    'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
    6161                )
    6262            );
     
    136136                    'comment_post_ID'  => $p,
    137137                    'comment_type'     => 'trackback',
    138                     'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ),
     138                    'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( 10 * $i ) ),
    139139                )
    140140            );
     
    227227            array(
    228228                'comment_post_ID'  => $p,
    229                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
     229                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
    230230            )
    231231        );
     
    233233            array(
    234234                'comment_post_ID'  => $p,
    235                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
     235                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
    236236            )
    237237        );
     
    240240                'comment_post_ID'  => $p,
    241241                'comment_approved' => 0,
    242                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
     242                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
    243243            )
    244244        );
     
    263263                array(
    264264                    'comment_post_ID'  => $posts[0],
    265                     'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
     265                    'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
    266266                )
    267267            );
     
    269269                array(
    270270                    'comment_post_ID'  => $posts[1],
    271                     'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
     271                    'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
    272272                )
    273273            );
     
    293293                array(
    294294                    'comment_post_ID'  => $post,
    295                     'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
     295                    'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
    296296                )
    297297            );
     
    301301                array(
    302302                    'comment_post_ID'  => $post,
    303                     'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ),
     303                    'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 59 ) ),
    304304                    'comment_parent'   => $parent,
    305305                )
     
    337337            array(
    338338                'comment_post_ID'  => $p,
    339                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
     339                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
    340340            )
    341341        );
     
    343343            array(
    344344                'comment_post_ID'  => $p,
    345                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
     345                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
    346346            )
    347347        );
     
    349349            array(
    350350                'comment_post_ID'  => $p,
    351                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
     351                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
    352352            )
    353353        );
     
    370370            array(
    371371                'comment_post_ID'  => $p,
    372                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
     372                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
    373373            )
    374374        );
     
    376376            array(
    377377                'comment_post_ID'  => $p,
    378                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
     378                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
    379379            )
    380380        );
     
    382382            array(
    383383                'comment_post_ID'  => $p,
    384                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
     384                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
    385385            )
    386386        );
     
    388388            array(
    389389                'comment_post_ID'  => $p,
    390                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
     390                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
    391391            )
    392392        );
     
    410410            array(
    411411                'comment_post_ID'  => $p,
    412                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
     412                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
    413413            )
    414414        );
     
    416416            array(
    417417                'comment_post_ID'  => $p,
    418                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
     418                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
    419419            )
    420420        );
     
    422422            array(
    423423                'comment_post_ID'  => $p,
    424                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
     424                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
    425425            )
    426426        );
     
    428428            array(
    429429                'comment_post_ID'  => $p,
    430                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
     430                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
    431431            )
    432432        );
Note: See TracChangeset for help on using the changeset viewer.