Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php
- Timestamp:
- 12/19/2017 04:22:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php
r5453 r6287 18 18 19 19 // The actual cron hooks. 20 add_action( 'plugin_directory_meta_sync', 21 add_action( 'plugin_directory_svn_sync', 20 add_action( 'plugin_directory_meta_sync', array( __NAMESPACE__ . '\Meta_Sync', 'cron_trigger' ) ); 21 add_action( 'plugin_directory_svn_sync', array( __NAMESPACE__ . '\SVN_Watcher', 'cron_trigger' ) ); 22 22 add_action( 'plugin_directory_update_api_check', array( __NAMESPACE__ . '\API_Update_Updater', 'cron_trigger' ) ); 23 23 24 24 // A cronjob to check cronjobs 25 add_action( 'plugin_directory_check_cronjobs', 25 add_action( 'plugin_directory_check_cronjobs', array( $this, 'register_cron_tasks' ) ); 26 26 27 27 // Register the wildcard cron hook tasks. … … 36 36 */ 37 37 public function register_schedules( $schedules ) { 38 $schedules['every_30s'] = array( 'interval' => 30, 'display' => 'Every 30 seconds' ); 39 $schedules['every_120s'] = array( 'interval' => 120, 'display' => 'Every 120 seconds' ); 38 $schedules['every_30s'] = array( 39 'interval' => 30, 40 'display' => 'Every 30 seconds', 41 ); 42 $schedules['every_120s'] = array( 43 'interval' => 120, 44 'display' => 'Every 120 seconds', 45 ); 40 46 41 47 return $schedules; … … 121 127 if ( ! $next_timestamp || $next_timestamp === $timestamp ) { 122 128 $events[] = [ 123 'hook' 124 'args' 125 'nextrun' 129 'hook' => $cron_item['_job']->hook, 130 'args' => $cron_item['_job']->args, 131 'nextrun' => $timestamp, 126 132 ]; 127 133 } … … 164 170 } 165 171 166 $event['_job']->args = $data['args'];172 $event['_job']->args = $data['args']; 167 173 $event['_job']->nextrun = $data['nextrun']; 168 174 $event['_job']->save(); … … 227 233 */ 228 234 public function register_cron_tasks() { 229 if ( ! wp_next_scheduled 235 if ( ! wp_next_scheduled( 'plugin_directory_meta_sync' ) ) { 230 236 wp_schedule_event( time() + 60, 'hourly', 'plugin_directory_meta_sync' ); 231 237 } 232 if ( ! wp_next_scheduled 238 if ( ! wp_next_scheduled( 'plugin_directory_svn_sync' ) ) { 233 239 wp_schedule_event( time() + 60, 'every_30s', 'plugin_directory_svn_sync' ); 234 240 } 235 if ( ! wp_next_scheduled 241 if ( ! wp_next_scheduled( 'plugin_directory_update_api_check' ) ) { 236 242 wp_schedule_event( time() + 60, 'hourly', 'plugin_directory_update_api_check' ); 237 243 } 238 if ( ! wp_next_scheduled 244 if ( ! wp_next_scheduled( 'plugin_directory_check_cronjobs' ) ) { 239 245 wp_schedule_event( time() + 60, 'every_120s', 'plugin_directory_check_cronjobs' ); 240 246 } … … 257 263 ); 258 264 259 foreach ( $cron_array as $timestamp => $handlers ) { 260 if ( ! is_numeric( $timestamp ) ) { 261 continue; 262 } 263 foreach ( $handlers as $hook => $jobs ) { 264 $pos = strpos( $hook, ':' ); 265 if ( ! $pos ) { 265 if ( is_array( $cron_array ) ) { 266 foreach ( $cron_array as $timestamp => $handlers ) { 267 if ( ! is_numeric( $timestamp ) ) { 266 268 continue; 267 269 } 268 270 269 $partial_hook = substr( $hook, 0, $pos ); 270 271 if ( isset( $wildcard_cron_tasks[ $partial_hook ] ) ) { 272 add_action( $hook, $wildcard_cron_tasks[ $partial_hook ], 10, PHP_INT_MAX ); 271 foreach ( $handlers as $hook => $jobs ) { 272 $pos = strpos( $hook, ':' ); 273 if ( ! $pos ) { 274 continue; 275 } 276 277 $partial_hook = substr( $hook, 0, $pos ); 278 279 if ( isset( $wildcard_cron_tasks[ $partial_hook ] ) ) { 280 add_action( $hook, $wildcard_cron_tasks[ $partial_hook ], 10, PHP_INT_MAX ); 281 } 273 282 } 274 283 }
Note: See TracChangeset
for help on using the changeset viewer.