mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 22:57:20 +00:00
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:
@@ -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 ) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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'] ) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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'] ) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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() ) {
|
||||
<title><?php bloginfo_rss( 'name' ); ?></title>
|
||||
<link><?php bloginfo_rss( 'url' ); ?></link>
|
||||
<description><?php bloginfo_rss( 'description' ); ?></description>
|
||||
<pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
|
||||
<pubDate><?php echo gmdate( 'D, d M Y H:i:s +0000' ); ?></pubDate>
|
||||
<language><?php bloginfo_rss( 'language' ); ?></language>
|
||||
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
|
||||
<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user