Make WordPress Core


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

    r43571 r45424  
    29502950                        array(
    29512951                                'comment_post_ID'  => self::$post_id,
    2952                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ),
    2953                         )
    2954                 );
    2955                 $c2 = self::factory()->comment->create(
    2956                         array(
    2957                                 'comment_post_ID'  => self::$post_id,
    2958                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
    2959                         )
    2960                 );
    2961                 $c3 = self::factory()->comment->create(
    2962                         array(
    2963                                 'comment_post_ID'  => self::$post_id,
    2964                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
     2952                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 50 ),
     2953                        )
     2954                );
     2955                $c2 = self::factory()->comment->create(
     2956                        array(
     2957                                'comment_post_ID'  => self::$post_id,
     2958                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
     2959                        )
     2960                );
     2961                $c3 = self::factory()->comment->create(
     2962                        array(
     2963                                'comment_post_ID'  => self::$post_id,
     2964                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
    29652965                        )
    29662966                );
     
    29682968                        array(
    29692969                                'comment_post_ID'  => self::$post_id,
    2970                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
     2970                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
    29712971                        )
    29722972                );
     
    29962996                        array(
    29972997                                'comment_post_ID'  => self::$post_id,
    2998                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ),
    2999                         )
    3000                 );
    3001                 $c2 = self::factory()->comment->create(
    3002                         array(
    3003                                 'comment_post_ID'  => self::$post_id,
    3004                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
    3005                         )
    3006                 );
    3007                 $c3 = self::factory()->comment->create(
    3008                         array(
    3009                                 'comment_post_ID'  => self::$post_id,
    3010                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
     2998                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 50 ),
     2999                        )
     3000                );
     3001                $c2 = self::factory()->comment->create(
     3002                        array(
     3003                                'comment_post_ID'  => self::$post_id,
     3004                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
     3005                        )
     3006                );
     3007                $c3 = self::factory()->comment->create(
     3008                        array(
     3009                                'comment_post_ID'  => self::$post_id,
     3010                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
    30113011                        )
    30123012                );
     
    30143014                        array(
    30153015                                'comment_post_ID'  => self::$post_id,
    3016                                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
     3016                                'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
    30173017                        )
    30183018                );
Note: See TracChangeset for help on using the changeset viewer.