From c77e771c849a85b63cef1b9457ad1a501a331afa Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 26 May 2019 00:12:54 +0000 Subject: [PATCH] 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 --- wp-admin/includes/ajax-actions.php | 2 +- wp-admin/includes/class-ftp.php | 2 +- wp-admin/includes/class-wp-filesystem-direct.php | 4 ++-- wp-admin/includes/class-wp-filesystem-ftpext.php | 2 +- wp-admin/includes/class-wp-filesystem-ssh2.php | 4 ++-- wp-admin/includes/dashboard.php | 6 +++--- wp-admin/includes/export.php | 8 ++++---- wp-admin/includes/post.php | 6 +++--- wp-admin/includes/upgrade.php | 2 +- wp-admin/options-permalink.php | 4 ++-- wp-includes/IXR/class-IXR-date.php | 12 ++++++------ wp-includes/IXR/class-IXR-server.php | 2 +- wp-includes/bookmark-template.php | 2 +- wp-includes/class-wp.php | 2 +- wp-includes/comment.php | 2 +- wp-includes/date.php | 6 +++--- wp-includes/deprecated.php | 2 +- wp-includes/formatting.php | 4 ++-- wp-includes/functions.php | 14 +++++++------- wp-includes/general-template.php | 16 ++++++++-------- wp-includes/link-template.php | 2 +- wp-includes/post.php | 6 +++--- wp-includes/rest-api.php | 4 ++-- .../endpoints/class-wp-rest-posts-controller.php | 2 +- .../endpoints/class-wp-rest-users-controller.php | 2 +- wp-includes/version.php | 2 +- 26 files changed, 60 insertions(+), 60 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 0f1f0f4e04..1056997831 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1476,7 +1476,7 @@ function wp_ajax_add_meta() { $post_data['post_status'] = 'draft'; $now = time(); /* translators: 1: Post creation date, 2: Post creation time */ - $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) ); + $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) ); $pid = edit_post( $post_data ); if ( $pid ) { diff --git a/wp-admin/includes/class-ftp.php b/wp-admin/includes/class-ftp.php index f1d40a4ffd..60fb2a19f6 100644 --- a/wp-admin/includes/class-ftp.php +++ b/wp-admin/includes/class-ftp.php @@ -207,7 +207,7 @@ class ftp_base { $b['month'] = $lucifer[5]; $b['day'] = $lucifer[6]; if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { - $b['year'] = date("Y"); + $b['year'] = gmdate("Y"); $b['hour'] = $l2[1]; $b['minute'] = $l2[2]; } else { diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php index 41839097f0..9b1757cc65 100644 --- a/wp-admin/includes/class-wp-filesystem-direct.php +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -598,8 +598,8 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { $struc['group'] = $this->group( $path . '/' . $entry ); $struc['size'] = $this->size( $path . '/' . $entry ); $struc['lastmodunix'] = $this->mtime( $path . '/' . $entry ); - $struc['lastmod'] = date( 'M j', $struc['lastmodunix'] ); - $struc['time'] = date( 'h:i:s', $struc['lastmodunix'] ); + $struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] ); + $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; if ( 'd' == $struc['type'] ) { diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 1db0a57917..26d1454c9a 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -621,7 +621,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $b['month'] = $lucifer[5]; $b['day'] = $lucifer[6]; if ( preg_match( '/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2 ) ) { - $b['year'] = date( 'Y' ); + $b['year'] = gmdate( 'Y' ); $b['hour'] = $l2[1]; $b['minute'] = $l2[2]; } else { diff --git a/wp-admin/includes/class-wp-filesystem-ssh2.php b/wp-admin/includes/class-wp-filesystem-ssh2.php index b87a195724..47eb8e7ae9 100644 --- a/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -744,8 +744,8 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { $struc['group'] = $this->group( $path . '/' . $entry ); $struc['size'] = $this->size( $path . '/' . $entry ); $struc['lastmodunix'] = $this->mtime( $path . '/' . $entry ); - $struc['lastmod'] = date( 'M j', $struc['lastmodunix'] ); - $struc['time'] = date( 'h:i:s', $struc['lastmodunix'] ); + $struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] ); + $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; if ( 'd' == $struc['type'] ) { diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index ad02909c74..9563fe37ab 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -863,11 +863,11 @@ function wp_dashboard_recent_posts( $args ) { $posts->the_post(); $time = get_the_time( 'U' ); - if ( date( 'Y-m-d', $time ) == $today ) { + if ( gmdate( 'Y-m-d', $time ) == $today ) { $relative = __( 'Today' ); - } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { + } elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) { $relative = __( 'Tomorrow' ); - } elseif ( date( 'Y', $time ) !== $year ) { + } elseif ( gmdate( 'Y', $time ) !== $year ) { /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */ $relative = date_i18n( __( 'M jS Y' ), $time ); } else { diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php index 5600371455..bdf9fad69c 100644 --- a/wp-admin/includes/export.php +++ b/wp-admin/includes/export.php @@ -79,7 +79,7 @@ function export_wp( $args = array() ) { if ( ! empty( $sitename ) ) { $sitename .= '.'; } - $date = date( 'Y-m-d' ); + $date = gmdate( 'Y-m-d' ); $wp_filename = $sitename . 'WordPress.' . $date . '.xml'; /** * Filters the export filename. @@ -129,11 +129,11 @@ function export_wp( $args = array() ) { } if ( $args['start_date'] ) { - $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime( $args['start_date'] ) ) ); + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", gmdate( 'Y-m-d', strtotime( $args['start_date'] ) ) ); } if ( $args['end_date'] ) { - $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) ); + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", gmdate( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) ); } } @@ -458,7 +458,7 @@ function export_wp( $args = array() ) { <?php bloginfo_rss( 'name' ); ?> - + diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index dc341bf9f3..8e31335944 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -170,10 +170,10 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { $hh = $post_data['hh']; $mn = $post_data['mn']; $ss = $post_data['ss']; - $aa = ( $aa <= 0 ) ? date( 'Y' ) : $aa; - $mm = ( $mm <= 0 ) ? date( 'n' ) : $mm; + $aa = ( $aa <= 0 ) ? gmdate( 'Y' ) : $aa; + $mm = ( $mm <= 0 ) ? gmdate( 'n' ) : $mm; $jj = ( $jj > 31 ) ? 31 : $jj; - $jj = ( $jj <= 0 ) ? date( 'j' ) : $jj; + $jj = ( $jj <= 0 ) ? gmdate( 'j' ) : $jj; $hh = ( $hh > 23 ) ? $hh - 24 : $hh; $mn = ( $mn > 59 ) ? $mn - 60 : $mn; $ss = ( $ss > 59 ) ? $ss - 60 : $ss; diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 4de9b109f4..38fdb9b25c 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -941,7 +941,7 @@ function upgrade_110() { $time_difference = $all_options->time_difference; - $server_time = time() + date( 'Z' ); + $server_time = time() + gmdate( 'Z' ); $weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS; $gmt_time = time(); diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 8e064faebe..a7cb9c5d84 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -202,11 +202,11 @@ $structures = array( - + - + diff --git a/wp-includes/IXR/class-IXR-date.php b/wp-includes/IXR/class-IXR-date.php index 7304f603b5..fc80cda4a1 100644 --- a/wp-includes/IXR/class-IXR-date.php +++ b/wp-includes/IXR/class-IXR-date.php @@ -37,12 +37,12 @@ class IXR_Date { function parseTimestamp($timestamp) { - $this->year = date('Y', $timestamp); - $this->month = date('m', $timestamp); - $this->day = date('d', $timestamp); - $this->hour = date('H', $timestamp); - $this->minute = date('i', $timestamp); - $this->second = date('s', $timestamp); + $this->year = gmdate('Y', $timestamp); + $this->month = gmdate('m', $timestamp); + $this->day = gmdate('d', $timestamp); + $this->hour = gmdate('H', $timestamp); + $this->minute = gmdate('i', $timestamp); + $this->second = gmdate('s', $timestamp); $this->timezone = ''; } diff --git a/wp-includes/IXR/class-IXR-server.php b/wp-includes/IXR/class-IXR-server.php index 095e44557b..9702ba28b7 100644 --- a/wp-includes/IXR/class-IXR-server.php +++ b/wp-includes/IXR/class-IXR-server.php @@ -151,7 +151,7 @@ EOD; header('Content-Type: text/xml; charset='.$charset); else header('Content-Type: text/xml'); - header('Date: '.date('r')); + header('Date: '.gmdate('r')); echo $xml; exit; } diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php index 78025b4550..85804125fb 100644 --- a/wp-includes/bookmark-template.php +++ b/wp-includes/bookmark-template.php @@ -87,7 +87,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) { $title .= ' ('; $title .= sprintf( __( 'Last updated: %s' ), - date( + gmdate( get_option( 'links_updated_date_format' ), $bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index b3bc907f9a..f939e33ac0 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -443,7 +443,7 @@ class WP { } if ( ! $wp_last_modified ) { - $wp_last_modified = date( 'D, d M Y H:i:s' ); + $wp_last_modified = gmdate( 'D, d M Y H:i:s' ); } $wp_last_modified .= ' GMT'; diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 5e89ef7695..6c2f332893 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -337,7 +337,7 @@ function get_lastcommentmodified( $timezone = 'server' ) { $comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" ); break; case 'server': - $add_seconds_server = date( 'Z' ); + $add_seconds_server = gmdate( 'Z' ); $comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) ); break; diff --git a/wp-includes/date.php b/wp-includes/date.php index 8d82db784e..fa464c6dac 100644 --- a/wp-includes/date.php +++ b/wp-includes/date.php @@ -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'] ) ) { diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index d928a2891f..dc6134eea6 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -960,7 +960,7 @@ function get_links($category = -1, $before = '', $after = '
', $between = ' if ( $show_updated ) if (substr($row->link_updated_f, 0, 2) != '00') - $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; + $title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; if ( '' != $title ) $title = ' title="' . $title . '"'; diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 2e349a0a3e..37cb532c12 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -3432,13 +3432,13 @@ function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) { if ( $tz ) { $datetime = date_create( $string, new DateTimeZone( 'UTC' ) ); if ( ! $datetime ) { - return date( $format, 0 ); + return gmdate( $format, 0 ); } $datetime->setTimezone( new DateTimeZone( $tz ) ); $string_localtime = $datetime->format( $format ); } else { if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) { - return date( $format, 0 ); + return gmdate( $format, 0 ); } $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); $string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index ce45499d0c..c9f817011a 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -41,7 +41,7 @@ function mysql2date( $format, $date, $translate = true ) { if ( $translate ) { return date_i18n( $format, $i ); } else { - return date( $format, $i ); + return gmdate( $format, $i ); } } @@ -111,12 +111,12 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa $dateformatstring = preg_replace( '/(?month ) ) && ( ! empty( $wp_locale->weekday ) ) ) { - $datemonth = $wp_locale->get_month( date( 'm', $i ) ); + $datemonth = $wp_locale->get_month( gmdate( 'm', $i ) ); $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); - $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); + $dateweekday = $wp_locale->get_weekday( gmdate( 'w', $i ) ); $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); - $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); - $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); + $datemeridiem = $wp_locale->get_meridiem( gmdate( 'a', $i ) ); + $datemeridiem_capital = $wp_locale->get_meridiem( gmdate( 'A', $i ) ); $dateformatstring = ' ' . $dateformatstring; $dateformatstring = preg_replace( '/([^\\\])D/', "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); $dateformatstring = preg_replace( '/([^\\\])F/', "\\1" . backslashit( $datemonth ), $dateformatstring ); @@ -177,7 +177,7 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa } } } - $j = @date( $dateformatstring, $i ); + $j = @gmdate( $dateformatstring, $i ); /** * Filters the date formatted based on the locale. @@ -415,7 +415,7 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) { $day = mktime( 0, 0, 0, $md, $mm, $my ); // The day of the week from the timestamp. - $weekday = date( 'w', $day ); + $weekday = gmdate( 'w', $day ); if ( ! is_numeric( $start_of_week ) ) { $start_of_week = get_option( 'start_of_week' ); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 633619cf4d..50323da6b9 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -2107,7 +2107,7 @@ function get_calendar( $initial = true, $echo = true ) { } $unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear ); - $last_day = date( 't', $unixmonth ); + $last_day = gmdate( 't', $unixmonth ); // Get the next and previous month and year with at least one post $previous = $wpdb->get_row( @@ -2133,7 +2133,7 @@ function get_calendar( $initial = true, $echo = true ) { ' . sprintf( $calendar_caption, $wp_locale->get_month( $thismonth ), - date( 'Y', $unixmonth ) + gmdate( 'Y', $unixmonth ) ) . ' '; @@ -2199,13 +2199,13 @@ function get_calendar( $initial = true, $echo = true ) { } // See how much we should pad in the beginning - $pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins ); + $pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins ); if ( 0 != $pad ) { $calendar_output .= "\n\t\t" . ' '; } $newrow = false; - $daysinmonth = (int) date( 't', $unixmonth ); + $daysinmonth = (int) gmdate( 't', $unixmonth ); for ( $day = 1; $day <= $daysinmonth; ++$day ) { if ( isset( $newrow ) && $newrow ) { @@ -2223,7 +2223,7 @@ function get_calendar( $initial = true, $echo = true ) { if ( in_array( $day, $daywithpost ) ) { // any posts today? - $date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) ); + $date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) ); /* translators: Post calendar label. %s: Date */ $label = sprintf( __( 'Posts published on %s' ), $date_format ); $calendar_output .= sprintf( @@ -2237,12 +2237,12 @@ function get_calendar( $initial = true, $echo = true ) { } $calendar_output .= ''; - if ( 6 == calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) { + if ( 6 == calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) { $newrow = true; } } - $pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ); + $pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ); if ( $pad != 0 && $pad != 7 ) { $calendar_output .= "\n\t\t" . ' '; } @@ -4452,7 +4452,7 @@ function get_the_generator( $type = '' ) { $gen = ''; break; case 'export': - $gen = ''; + $gen = ''; break; } diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 3526239d3f..77b18c6fca 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -212,7 +212,7 @@ function get_permalink( $post = 0, $leavename = false ) { $author = $authordata->user_nicename; } - $date = explode( ' ', date( 'Y m d H i s', $unixtime ) ); + $date = explode( ' ', gmdate( 'Y m d H i s', $unixtime ) ); $rewritereplace = array( $date[0], diff --git a/wp-includes/post.php b/wp-includes/post.php index 54e6c14f3b..5856af56ca 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -6031,8 +6031,8 @@ function wp_check_for_changed_slugs( $post_id, $post, $post_before ) { * @param WP_Post $post_before The Previous Post Object */ function wp_check_for_changed_dates( $post_id, $post, $post_before ) { - $previous_date = date( 'Y-m-d', strtotime( $post_before->post_date ) ); - $new_date = date( 'Y-m-d', strtotime( $post->post_date ) ); + $previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) ); + $new_date = gmdate( 'Y-m-d', strtotime( $post->post_date ) ); // Don't bother if it hasn't changed. if ( $new_date == $previous_date ) { return; @@ -6286,7 +6286,7 @@ function _get_last_post_time( $timezone, $field, $post_type = 'any' ) { $date = $wpdb->get_var( "SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1" ); break; case 'server': - $add_seconds_server = date( 'Z' ); + $add_seconds_server = gmdate( 'Z' ); $date = $wpdb->get_var( "SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1" ); break; } diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 1c73b97824..adcca17d3b 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -924,10 +924,10 @@ function rest_get_date_with_gmt( $date, $is_utc = false ) { // Timezone conversion needs to be handled differently between these two // cases. if ( ! $is_utc && ! $has_timezone ) { - $local = date( 'Y-m-d H:i:s', $date ); + $local = gmdate( 'Y-m-d H:i:s', $date ); $utc = get_gmt_from_date( $local ); } else { - $utc = date( 'Y-m-d H:i:s', $date ); + $utc = gmdate( 'Y-m-d H:i:s', $date ); $local = get_date_from_gmt( $utc ); } diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index f24bc068c8..ee8af5b3ad 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1478,7 +1478,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { // based on the `post_modified` field with the site's timezone // offset applied. if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { - $post_modified_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) ); + $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) ); } else { $post_modified_gmt = $post->post_modified_gmt; } diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php index 8aab4ca5ad..19c3019881 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php @@ -925,7 +925,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller { } if ( in_array( 'registered_date', $fields, true ) ) { - $data['registered_date'] = date( 'c', strtotime( $user->user_registered ) ); + $data['registered_date'] = gmdate( 'c', strtotime( $user->user_registered ) ); } if ( in_array( 'capabilities', $fields, true ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 22a7ce7fb8..632a3d9e8e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45423'; +$wp_version = '5.3-alpha-45424'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.