Make WordPress Core

Changeset 21954


Ignore:
Timestamp:
09/23/2012 04:57:21 PM (12 years ago)
Author:
nacin
Message:

Use $gmt_time rather than $local_time in cron, since it uses GMT/UTC and not a local timestamp. see #14391.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-cron.php

    r19722 r21954  
    4949
    5050$keys = array_keys( $crons );
    51 $local_time = microtime( true );
     51$gmt_time = microtime( true );
    5252
    53 if ( isset($keys[0]) && $keys[0] > $local_time )
     53if ( isset($keys[0]) && $keys[0] > $gmt_time )
    5454    die();
    5555
     
    6060    if ( empty( $_GET[ 'doing_wp_cron' ] ) ) {
    6161        // Called from external script/job. Try setting a lock.
    62         if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $local_time ) )
     62        if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) )
    6363            return;
    6464        $doing_cron_transient = $doing_wp_cron = sprintf( '%.22F', microtime( true ) );
     
    7474
    7575foreach ( $crons as $timestamp => $cronhooks ) {
    76     if ( $timestamp > $local_time )
     76    if ( $timestamp > $gmt_time )
    7777        break;
    7878
  • trunk/wp-includes/cron.php

    r21293 r21954  
    193193 * @return null Cron could not be spawned, because it is not needed to run.
    194194 */
    195 function spawn_cron( $local_time = 0 ) {
    196 
    197     if ( ! $local_time )
    198         $local_time = microtime( true );
     195function spawn_cron( $gmt_time = 0 ) {
     196
     197    if ( ! $gmt_time )
     198        $gmt_time = microtime( true );
    199199
    200200    if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
     
    207207    $lock = get_transient('doing_cron');
    208208
    209     if ( $lock > $local_time + 10*60 )
     209    if ( $lock > $gmt_time + 10*60 )
    210210        $lock = 0;
    211211
    212212    // don't run if another process is currently running it or more than once every 60 sec.
    213     if ( $lock + WP_CRON_LOCK_TIMEOUT > $local_time )
     213    if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time )
    214214        return;
    215215
     
    220220
    221221    $keys = array_keys( $crons );
    222     if ( isset($keys[0]) && $keys[0] > $local_time )
     222    if ( isset($keys[0]) && $keys[0] > $gmt_time )
    223223        return;
    224224
     
    227227            return;
    228228
    229         $doing_wp_cron = sprintf( '%.22F', $local_time );
     229        $doing_wp_cron = sprintf( '%.22F', $gmt_time );
    230230        set_transient( 'doing_cron', $doing_wp_cron );
    231231
     
    242242    }
    243243
    244     $doing_wp_cron = sprintf( '%.22F', $local_time );
     244    $doing_wp_cron = sprintf( '%.22F', $gmt_time );
    245245    set_transient( 'doing_cron', $doing_wp_cron );
    246246
     
    270270        return;
    271271
    272     $local_time = microtime( true );
     272    $gmt_time = microtime( true );
    273273    $keys = array_keys( $crons );
    274     if ( isset($keys[0]) && $keys[0] > $local_time )
     274    if ( isset($keys[0]) && $keys[0] > $gmt_time )
    275275        return;
    276276
    277277    $schedules = wp_get_schedules();
    278278    foreach ( $crons as $timestamp => $cronhooks ) {
    279         if ( $timestamp > $local_time ) break;
     279        if ( $timestamp > $gmt_time ) break;
    280280        foreach ( (array) $cronhooks as $hook => $args ) {
    281281            if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
    282282                continue;
    283             spawn_cron( $local_time );
     283            spawn_cron( $gmt_time );
    284284            break 2;
    285285        }
Note: See TracChangeset for help on using the changeset viewer.