Changeset 3634

Show
Ignore:
Timestamp:
03/07/06 21:43:59 (2 years ago)
Author:
ryan
Message:

Cron improvements from masquerade. #2425

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/functions-post.php

    r3539 r3634  
    211211    } 
    212212 
    213     if ( 'future' == $post_status ) 
    214         wp_schedule_event(mysql2date('U', $post_date), 'once', 'publish_future_post', $post_ID); 
    215  
     213    if ( 'future' == $post_status ) { 
     214        wp_schedule_single_event(mysql2date('U', $post_date), 'publish_future_post', $post_ID); 
     215    } 
     216         
    216217    do_action('save_post', $post_ID); 
    217218    do_action('wp_insert_post', $post_ID); 
  • trunk/wp-includes/functions.php

    r3633 r3634  
    24242424} 
    24252425 
    2426 function wp_schedule_event($timestamp, $recurrence, $hook) { 
    2427     $args = array_slice(func_get_args(), 3); 
    2428     $crons = get_option('cron'); 
    2429     $crons[$timestamp][$hook] = array('recur' => $recurrence, 'args' => $args); 
    2430     ksort($crons); 
    2431     update_option('cron', $crons); 
    2432 } 
    2433  
    2434 function wp_unschedule_event($timestamp, $hook) { 
    2435     $crons = get_option('cron'); 
    2436     unset($crons[$timestamp][$hook]); 
    2437     if ( empty($crons[$timestamp]) ) 
    2438         unset($crons[$timestamp]); 
    2439     update_option('cron', $crons); 
    2440 } 
    2441  
    2442 function wp_clear_scheduled_hook($hook) { 
    2443     while($timestamp = next_scheduled('scheduled_hook')) 
    2444         wp_unschedule_event($timestamp, 'scheduled_hook'); 
    2445 } 
    2446  
    2447 function next_scheduled($hook) { 
    2448     $crons = get_option('cron'); 
    2449     if ( empty($crons) ) 
    2450         return false; 
    2451     foreach($crons as $timestamp => $cron) { 
    2452         //if($timestamp <= time()) continue; 
    2453         if(isset($cron[$hook])) return $timestamp; 
    2454     } 
    2455     return false; 
    2456 } 
    2457  
    2458 function spawn_cron() { 
    2459     if (array_shift(array_keys(get_option('cron'))) > time()) return; 
    2460  
    2461     $cron_url = get_settings('siteurl') . '/wp-cron.php'; 
    2462     $parts = parse_url($cron_url); 
    2463     $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); 
    2464     if ( $argyle ) 
    2465         fputs($argyle, "GET {$parts['path']}?time=" . time() . '&check=' 
    2466         . md5(DB_PASS . '187425') . " HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n"); 
    2467 } 
    2468  
    2469 function wp_cron() { 
    2470     $crons = get_option('cron'); 
    2471     if (!is_array($crons) || array_shift(array_keys($crons)) > time()) 
    2472         return; 
    2473  
    2474     foreach ($crons as $timestamp => $cronhooks) { 
    2475         if ($timestamp > current_time( 'timestamp' )) break; 
    2476         foreach($cronhooks as $hook => $args) { 
    2477             do_action($hook, $args['args']); 
    2478             $recurrence = $args['recur']; 
    2479             if ( 'hourly' == $recurrence ) { 
    2480                 $args = array_merge( array($timestamp + 3600, $recurrence, $hook), $args['args']); 
    2481                 call_user_func_array('wp_schedule_event', $args); 
    2482             } else if ( 'daily' == $recurrence ) { 
    2483                 $args = array_merge( array($timestamp + 86400, $recurrence, $hook), $args['args']); 
    2484                 call_user_func_array('wp_schedule_event', $args); 
    2485             } 
    2486  
    2487             wp_unschedule_event($timestamp, $hook); 
    2488         } 
    2489     } 
    2490 } 
    2491  
    24922426function privacy_ping_filter( $sites ) { 
    24932427    if ( get_option('blog_public') ) 
  • trunk/wp-settings.php

    r3596 r3634  
    144144require (ABSPATH . WPINC . '/template-functions-bookmarks.php'); 
    145145require (ABSPATH . WPINC . '/kses.php'); 
     146require (ABSPATH . WPINC . '/cron.php'); 
    146147require (ABSPATH . WPINC . '/version.php'); 
    147148require (ABSPATH . WPINC . '/deprecated.php');