Make WordPress Core

Changeset 8927 for trunk/wp-cron.php


Ignore:
Timestamp:
09/18/2008 07:09:38 AM (17 years ago)
Author:
azaozz
Message:

Cron improvement, props hailin, fixes #7068

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-cron.php

    r7991 r8927  
    2424    exit;
    2525
    26 if ( get_option('doing_cron') > time() )
    27     exit;
    28 
    29 update_option('doing_cron', time() + 30);
     26$local_time = time();
    3027
    3128$crons = _get_cron_array();
    32 $keys = array_keys($crons);
    33 if (!is_array($crons) || $keys[0] > time())
     29$keys = array_keys( $crons );
     30
     31if (!is_array($crons) || $keys[0] > $local_time) {
     32    update_option('doing_cron', 0);
    3433    return;
     34}
    3535
    36 foreach ($crons as $timestamp => $cronhooks) {
    37     if ($timestamp > time()) break;
     36foreach ($crons as $timestamp  => $cronhooks) {
     37
     38    if ( $timestamp > $local_time )
     39        break;
     40
    3841    foreach ($cronhooks as $hook => $keys) {
    39         foreach ($keys as $key => $args) {
    40             $schedule = $args['schedule'];
     42
     43        foreach ($keys as $k => $v) {
     44
     45            $schedule = $v['schedule'];
     46
    4147            if ($schedule != false) {
    42                 $new_args = array($timestamp, $schedule, $hook, $args['args']);
     48                $new_args = array($timestamp, $schedule, $hook, $v['args']);
    4349                call_user_func_array('wp_reschedule_event', $new_args);
    4450            }
    45             wp_unschedule_event($timestamp, $hook, $args['args']);
    46             do_action_ref_array($hook, $args['args']);
     51
     52            wp_unschedule_event($timestamp, $hook, $v['args']);
     53
     54            do_action_ref_array($hook, $v['args']);
    4755        }
    4856    }
     
    5159update_option('doing_cron', 0);
    5260
     61die();
     62
    5363?>
Note: See TracChangeset for help on using the changeset viewer.