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/functions/getArchives.php

    r43571 r45424  
    1616                parent::setUp();
    1717
    18                 $this->month_url = get_month_link( date( 'Y' ), date( 'm' ) );
    19                 $this->year_url  = get_year_link( date( 'Y' ) );
     18                $this->month_url = get_month_link( gmdate( 'Y' ), gmdate( 'm' ) );
     19                $this->year_url  = get_year_link( gmdate( 'Y' ) );
    2020        }
    2121
    … …  
    3131
    3232        function test_wp_get_archives_default() {
    33                 $expected['default'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>';
     33                $expected['default'] = "<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></li>';
    3434                $this->assertEquals( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) );
    3535        }
    3636
    3737        function test_wp_get_archives_type() {
    38                 $expected['type'] = "<li><a href='" . $this->year_url . "'>" . date( 'Y' ) . '</a></li>';
     38                $expected['type'] = "<li><a href='" . $this->year_url . "'>" . gmdate( 'Y' ) . '</a></li>';
    3939                $this->assertEquals(
    4040                        $expected['type'],
    … …  
    8787
    8888        function test_wp_get_archives_format() {
    89                 $expected['format'] = "<option value='" . $this->month_url . "'> " . date( 'F Y' ) . ' </option>';
     89                $expected['format'] = "<option value='" . $this->month_url . "'> " . gmdate( 'F Y' ) . ' </option>';
    9090                $this->assertEquals(
    9191                        $expected['format'],
    … …  
    102102
    103103        function test_wp_get_archives_before_and_after() {
    104                 $expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></div>';
     104                $expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></div>';
    105105                $this->assertEquals(
    106106                        $expected['before_and_after'],
    … …  
    119119
    120120        function test_wp_get_archives_show_post_count() {
    121                 $expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a>&nbsp;(8)</li>';
     121                $expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a>&nbsp;(8)</li>';
    122122                $this->assertEquals(
    123123                        $expected['show_post_count'],
    … …  
    134134
    135135        function test_wp_get_archives_echo() {
    136                 $expected['echo'] = "\t<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>' . "\n";
     136                $expected['echo'] = "\t<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></li>' . "\n";
    137137                $this->expectOutputString( $expected['echo'] );
    138138                wp_get_archives( array( 'echo' => true ) );
    … …  
    148148                );
    149149
    150                 $date_full             = date( 'F Y' );
     150                $date_full             = gmdate( 'F Y' );
    151151                $oct_url               = get_month_link( 2012, 10 );
    152152                $expected['order_asc'] = <<<EOF
Note: See TracChangeset for help on using the changeset viewer.