Make WordPress Core


Ignore:
Timestamp:
09/23/2012 04:57:21 PM (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.