Ticket #51716: 51716.diff
File 51716.diff, 3.1 KB (added by , 5 years ago) |
---|
-
wp-cron.php
1 1 <?php 2 2 /** 3 * A pseudo- cron daemon for scheduling WordPress tasks.3 * A pseudo-CRON daemon for scheduling WordPress tasks 4 4 * 5 * WP -Cron is triggered when the site receives a visit. In the scenario5 * WP Cron is triggered when the site receives a visit. In the scenario 6 6 * where a site may not receive enough visits to execute scheduled tasks 7 7 * in a timely manner, this file can be called directly or via a server 8 * crondaemon for X number of times.8 * CRON daemon for X number of times. 9 9 * 10 10 * Defining DISABLE_WP_CRON as true and calling this file directly are 11 11 * mutually exclusive and the latter does not rely on the former to work. 12 12 * 13 13 * The HTTP request to this file will not slow down the visitor who happens to 14 * visit when a scheduled cron event runs.14 * visit when the cron job is needed to run. 15 15 * 16 16 * @package WordPress 17 17 */ … … 33 33 } 34 34 35 35 /** 36 * Tell WordPress we are doing the crontask.36 * Tell WordPress we are doing the CRON task. 37 37 * 38 38 * @var bool 39 39 */ … … 109 109 return; 110 110 } 111 111 112 /* 113 * Store cron job to be executed. 114 */ 115 $cron_jobs = []; 116 117 // Schedule and reschedule cron jobs. 112 118 foreach ( $crons as $timestamp => $cronhooks ) { 113 119 if ( $timestamp > $gmt_time ) { 114 120 break; … … 126 132 127 133 wp_unschedule_event( $timestamp, $hook, $v['args'] ); 128 134 129 /** 130 * Fires scheduled events. 131 * 132 * @ignore 133 * @since 2.1.0 134 * 135 * @param string $hook Name of the hook that was scheduled to be fired. 136 * @param array $args The arguments to be passed to the hook. 137 */ 138 do_action_ref_array( $hook, $v['args'] ); 135 // Register jobs to be executed. 136 $cron_jobs[] = [ 137 'timestamp' => $timestamp, 138 'hook' => $hook, 139 'args' => isset( $v['args'] ) ? (array) $v['args'] : [], 140 'schedule' => $schedule, 141 ]; 139 142 140 143 // If the hook ran too long and another cron process stole the lock, quit. 141 144 if ( _get_cron_lock() !== $doing_wp_cron ) { 145 do_action( 'wp_cron_schedule_aborted' ); 142 146 return; 143 147 } 144 148 } … … 149 153 delete_transient( 'doing_cron' ); 150 154 } 151 155 156 // Let's do the cron jobs. 157 foreach ( $cron_jobs as $job ) { 158 /** 159 * Get cron executor. 160 * 161 * By default, `do_action_ref_array` will called. 162 * 163 * @since 5.6.0 164 * 165 * @param array $jobs Cron task to be executed. 166 */ 167 $callback = apply_filters( 'wp_cron_job_callback', 'do_action_ref_array', $job ); 168 try { 169 do_action( 'wp_cron_before_execution', $job ); 170 /** 171 * Fires scheduled events by callback. 172 * 173 * By default, `do_action_ref_array` will called. 174 * 175 * @ignore 176 * @since 2.1.0 177 * @since 5.6.0 This hook runs by default, but can be overridden. 178 * 179 * @param string $hook Name of the hook that was scheduled to be fired. 180 * @param array $args The arguments to be passed to the hook. 181 */ 182 call_user_func_array( $callback, [ $job['hook'], $job['args'] ] ); 183 do_action( 'wp_cron_after_execution', $job ); 184 } catch ( Exception $e ) { 185 do_action( 'wp_cron_execution_error', $e ); 186 } 187 } 188 152 189 die();