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.

git-svn-id: https://develop.svn.wordpress.org/trunk@45424 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-05-26 00:11:37 +00:00
parent 716e25e0df
commit 10855438ea
49 changed files with 231 additions and 231 deletions

View File

@@ -336,8 +336,8 @@ class Tests_URL extends WP_UnitTestCase {
public function test_get_adjacent_post() {
$now = time();
$post_id = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
$post_id2 = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
$post_id = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ) ) );
$post_id2 = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now ) ) );
if ( ! isset( $GLOBALS['post'] ) ) {
$GLOBALS['post'] = null;
@@ -379,13 +379,13 @@ class Tests_URL extends WP_UnitTestCase {
array(
'post_author' => $u,
'post_status' => 'private',
'post_date' => date( 'Y-m-d H:i:s', $now - 1 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ),
)
);
$p2 = self::factory()->post->create(
array(
'post_author' => $u,
'post_date' => date( 'Y-m-d H:i:s', $now ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
@@ -417,13 +417,13 @@ class Tests_URL extends WP_UnitTestCase {
array(
'post_author' => $u1,
'post_status' => 'private',
'post_date' => date( 'Y-m-d H:i:s', $now - 1 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ),
)
);
$p2 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_date' => date( 'Y-m-d H:i:s', $now ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
@@ -454,20 +454,20 @@ class Tests_URL extends WP_UnitTestCase {
$p1 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_date' => date( 'Y-m-d H:i:s', $now - 2 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 2 ),
)
);
$p2 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_status' => 'private',
'post_date' => date( 'Y-m-d H:i:s', $now - 1 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ),
)
);
$p3 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_date' => date( 'Y-m-d H:i:s', $now ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now ),
)
);