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. Built from https://develop.svn.wordpress.org/trunk@45424 git-svn-id: http://core.svn.wordpress.org/trunk@45235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -317,7 +317,7 @@ class WP_Date_Query {
|
||||
$_year = $date_query['year'];
|
||||
}
|
||||
|
||||
$max_days_of_year = date( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1;
|
||||
$max_days_of_year = gmdate( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1;
|
||||
} else {
|
||||
// otherwise we use the max of 366 (leap-year)
|
||||
$max_days_of_year = 366;
|
||||
@@ -352,7 +352,7 @@ class WP_Date_Query {
|
||||
* If we have a specific year, use it to calculate number of weeks.
|
||||
* Note: the number of weeks in a year is the date in which Dec 28 appears.
|
||||
*/
|
||||
$week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
|
||||
$week_count = gmdate( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
|
||||
|
||||
} else {
|
||||
// Otherwise set the week-count to a maximum of 53.
|
||||
@@ -923,7 +923,7 @@ class WP_Date_Query {
|
||||
}
|
||||
|
||||
if ( ! isset( $datetime['day'] ) ) {
|
||||
$datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
|
||||
$datetime['day'] = ( $default_to_max ) ? (int) gmdate( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
|
||||
}
|
||||
|
||||
if ( ! isset( $datetime['hour'] ) ) {
|
||||
|
||||
Reference in New Issue
Block a user