Changeset 4189
- Timestamp:
- 09/13/2006 11:54:15 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-cron.php
r4077 r4189 7 7 exit; 8 8 9 $crons = get_option('cron');9 $crons = _get_cron_array(); 10 10 $keys = array_keys($crons); 11 11 if (!is_array($crons) || $keys[0] > time()) … … 13 13 foreach ($crons as $timestamp => $cronhooks) { 14 14 if ($timestamp > time()) break; 15 foreach($cronhooks as $hook => $args) { 16 do_action($hook, $args['args']); 17 $schedule = $args['schedule']; 18 if($schedule != false) { 19 $args = array_merge( array($timestamp, $schedule, $hook), $args['args']); 20 call_user_func_array('wp_reschedule_event', $args); 15 foreach ($cronhooks as $hook => $keys) { 16 foreach ($keys as $key => $args) { 17 do_action_ref_array($hook, $args['args']); 18 $schedule = $args['schedule']; 19 if ($schedule != false) { 20 $args = array_merge( array($timestamp, $schedule, $hook), $args['args']); 21 call_user_func_array('wp_reschedule_event', $args); 22 } 23 wp_unschedule_event($timestamp, $hook); 21 24 } 22 wp_unschedule_event($timestamp, $hook );25 wp_unschedule_event($timestamp, $hook, $args); 23 26 } 24 27 } -
trunk/wp-includes/cron.php
r4144 r4189 3 3 function wp_schedule_single_event( $timestamp, $hook ) { 4 4 $args = array_slice( func_get_args(), 2 ); 5 $crons = get_option( 'cron' ); 6 $crons[$timestamp][$hook] = array( 'schedule' => false, 'args' => $args ); 5 $crons = _get_cron_array(); 6 $key = md5(serialize($args)); 7 $crons[$timestamp][$hook][$key] = array( 'schedule' => false, 'args' => $args ); 7 8 ksort( $crons ); 8 update_option( 'cron',$crons );9 _set_cron_array( $crons ); 9 10 } 10 11 11 12 function wp_schedule_event( $timestamp, $recurrence, $hook ) { 12 13 $args = array_slice( func_get_args(), 3 ); 13 $crons = get_option( 'cron');14 $crons = _get_cron_array(); 14 15 $schedules = wp_get_schedules(); 16 $key = md5(serialize($args)); 15 17 if ( !isset( $schedules[$recurrence] ) ) 16 18 return false; 17 $crons[$timestamp][$hook] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );19 $crons[$timestamp][$hook][$key] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] ); 18 20 ksort( $crons ); 19 update_option( 'cron',$crons );21 _set_cron_array( $crons ); 20 22 } 21 23 22 24 function wp_reschedule_event( $timestamp, $recurrence, $hook ) { 23 25 $args = array_slice( func_get_args(), 3 ); 24 $crons = get_option( 'cron');26 $crons = _get_cron_array(); 25 27 $schedules = wp_get_schedules(); 28 $key = md5(serialize($args)); 26 29 $interval = 0; 27 30 … … 31 34 // Now we try to get it from the saved interval in case the schedule disappears 32 35 if ( 0 == $interval ) 33 $interval = $crons[$timestamp][$hook][ 'interval'];36 $interval = $crons[$timestamp][$hook][$key]['interval']; 34 37 // Now we assume something is wrong and fail to schedule 35 38 if ( 0 == $interval ) … … 39 42 $timestamp += $interval; 40 43 41 wp_schedule_event( $timestamp, $recurrence, $hook );44 wp_schedule_event( $timestamp, $recurrence, $hook, $args ); 42 45 } 43 46 44 function wp_unschedule_event( $timestamp, $hook ) { 45 $crons = get_option( 'cron' ); 46 unset( $crons[$timestamp][$hook] ); 47 function wp_unschedule_event( $timestamp, $hook, $args = array() ) { 48 $crons = _get_cron_array(); 49 $key = md5(serialize($args)); 50 unset( $crons[$timestamp][$hook][$key] ); 51 if ( empty($crons[$timestamp][$hook]) ) 52 unset( $crons[$timestamp][$hook] ); 47 53 if ( empty($crons[$timestamp]) ) 48 54 unset( $crons[$timestamp] ); 49 update_option( 'cron',$crons );55 _set_cron_array( $crons ); 50 56 } 51 57 … … 54 60 55 61 while ( $timestamp = wp_next_scheduled( $hook, $args ) ) 56 wp_unschedule_event( $timestamp, $hook );62 wp_unschedule_event( $timestamp, $hook, $args ); 57 63 } 58 64 59 function wp_next_scheduled( $hook, $args = '' ) { 60 $crons = get_option( 'cron' ); 65 function wp_next_scheduled( $hook, $args = array() ) { 66 $crons = _get_cron_array(); 67 $key = md5(serialize($args)); 61 68 if ( empty($crons) ) 62 69 return false; 63 foreach ( $crons as $timestamp => $cron ) 64 if ( isset( $cron[$hook] ) ) { 65 if ( empty($args) ) 66 return $timestamp; 67 if ( $args == $cron[$hook]['args'] ) 68 return $timestamp; 69 } 70 foreach ( $crons as $timestamp => $cron ) { 71 if ( isset( $cron[$hook][$key] ) ) 72 return $timestamp; 73 } 70 74 return false; 71 75 } 72 76 73 77 function spawn_cron() { 74 $crons = get_option( 'cron');78 $crons = _get_cron_array(); 75 79 76 80 if ( !is_array($crons) ) … … 93 97 94 98 function wp_cron() { 95 $crons = get_option( 'cron');99 $crons = _get_cron_array(); 96 100 97 101 if ( !is_array($crons) ) … … 122 126 } 123 127 128 // 129 // Private functions 130 // 131 132 function _get_cron_array() { 133 $cron = get_option('cron'); 134 if ( ! is_array($cron) ) 135 return false; 136 137 if ( !isset($cron['version']) ) 138 $cron = _upgrade_cron_array($cron); 139 140 unset($cron['version']); 141 142 return $cron; 143 } 144 145 function _set_cron_array($cron) { 146 $cron['version'] = 2; 147 update_option( 'cron', $cron ); 148 } 149 150 function _upgrade_cron_array($cron) { 151 if ( isset($cron['version']) && 2 == $cron['version']) 152 return $cron; 153 154 $new_cron = array(); 155 156 foreach ($cron as $timestamp => $hooks) { 157 foreach ( $hooks as $hook => $args ) { 158 $key = md5(serialize($args['args'])); 159 $new_cron[$timestamp][$hook][$key] = $args; 160 } 161 } 162 163 $new_cron['version'] = 2; 164 update_option( 'cron', $new_cron ); 165 return $new_cron; 166 } 167 124 168 ?> -
trunk/wp-includes/post.php
r4180 r4189 699 699 // Schedule publication. 700 700 if ( 'future' == $post_status ) 701 wp_schedule_single_event( mysql2date('U', $post_date), 'publish_future_post', $post_ID);701 wp_schedule_single_event(strtotime($post->post_date_gmt. ' GMT'), 'publish_future_post', $post_ID); 702 702 703 703 do_action('save_post', $post_ID);
Note: See TracChangeset
for help on using the changeset viewer.