Make WordPress Core


Ignore:
Timestamp:
05/26/2019 12:11:37 AM (6 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/src/wp-includes/post.php

    r45422 r45424  
    60326032 */
    60336033function wp_check_for_changed_dates( $post_id, $post, $post_before ) {
    6034     $previous_date = date( 'Y-m-d', strtotime( $post_before->post_date ) );
    6035     $new_date      = date( 'Y-m-d', strtotime( $post->post_date ) );
     6034    $previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) );
     6035    $new_date      = gmdate( 'Y-m-d', strtotime( $post->post_date ) );
    60366036    // Don't bother if it hasn't changed.
    60376037    if ( $new_date == $previous_date ) {
     
    62876287            break;
    62886288        case 'server':
    6289             $add_seconds_server = date( 'Z' );
     6289            $add_seconds_server = gmdate( 'Z' );
    62906290            $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" );
    62916291            break;
Note: See TracChangeset for help on using the changeset viewer.