~canonical-sysadmins/wordpress/4.8.3

« back to all changes in this revision

Viewing changes to wp-includes/cron.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * @param int $timestamp Timestamp for when to run the event.
19
19
 * @param string $hook Action hook to execute when cron is run.
20
20
 * @param array $args Optional. Arguments to pass to the hook's callback function.
 
21
 * @return void|false
21
22
 */
22
23
function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
23
24
        // don't schedule a duplicate if there's already an identical event due within 10 minutes of it
66
67
 * @param string $recurrence How often the event should recur.
67
68
 * @param string $hook Action hook to execute when cron is run.
68
69
 * @param array $args Optional. Arguments to pass to the hook's callback function.
69
 
 * @return false|null False on failure, null when complete with scheduling event.
 
70
 * @return false|void False when does not schedule event.
70
71
 */
71
72
function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
72
73
        $crons = _get_cron_array();
99
100
 * @param string $recurrence How often the event should recur.
100
101
 * @param string $hook Action hook to execute when cron is run.
101
102
 * @param array $args Optional. Arguments to pass to the hook's callback function.
102
 
 * @return false|null False on failure. Null when event is rescheduled.
 
103
 * @return false|void False when does not schedule event.
103
104
 */
104
105
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
105
106
        $crons = _get_cron_array();
195
196
 *
196
197
 * @param string $hook Action hook to execute when cron is run.
197
198
 * @param array $args Optional. Arguments to pass to the hook's callback function.
198
 
 * @return bool|int The UNIX timestamp of the next time the scheduled event will occur.
 
199
 * @return false|int The UNIX timestamp of the next time the scheduled event will occur.
199
200
 */
200
201
function wp_next_scheduled( $hook, $args = array() ) {
201
202
        $crons = _get_cron_array();
213
214
 * Send request to run cron through HTTP request that doesn't halt page loading.
214
215
 *
215
216
 * @since 2.1.0
216
 
 *
217
 
 * @return null Cron could not be spawned, because it is not needed to run.
218
217
 */
219
218
function spawn_cron( $gmt_time = 0 ) {
220
 
 
221
219
        if ( ! $gmt_time )
222
220
                $gmt_time = microtime( true );
223
221
 
225
223
                return;
226
224
 
227
225
        /*
228
 
        * multiple processes on multiple web servers can run this code concurrently
229
 
        * try to make this as atomic as possible by setting doing_cron switch
230
 
        */
 
226
         * Get the cron lock, which is a unix timestamp of when the last cron was spawned
 
227
         * and has not finished running.
 
228
         *
 
229
         * Multiple processes on multiple web servers can run this code concurrently,
 
230
         * this lock attempts to make spawning as atomic as possible.
 
231
         */
231
232
        $lock = get_transient('doing_cron');
232
233
 
233
234
        if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS )
266
267
                return;
267
268
        }
268
269
 
 
270
        // Set the cron lock with the current unix timestamp, when the cron is being spawned.
269
271
        $doing_wp_cron = sprintf( '%.22F', $gmt_time );
270
272
        set_transient( 'doing_cron', $doing_wp_cron );
271
273
 
306
308
 * Run scheduled callbacks or spawn cron for all scheduled events.
307
309
 *
308
310
 * @since 2.1.0
309
 
 *
310
 
 * @return null When doesn't need to run Cron.
311
311
 */
312
312
function wp_cron() {
313
 
 
314
313
        // Prevent infinite loops caused by lack of wp-cron.php
315
314
        if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) )
316
315
                return;
388
387
 *
389
388
 * @param string $hook Action hook to execute when cron is run.
390
389
 * @param array $args Optional. Arguments to pass to the hook's callback function.
391
 
 * @return string|bool False, if no schedule. Schedule on success.
 
390
 * @return string|false False, if no schedule. Schedule on success.
392
391
 */
393
392
function wp_get_schedule($hook, $args = array()) {
394
393
        $crons = _get_cron_array();
412
411
 * @since 2.1.0
413
412
 * @access private
414
413
 *
415
 
 * @return array CRON info array.
 
414
 * @return false|array CRON info array.
416
415
 */
417
416
function _get_cron_array()  {
418
417
        $cron = get_option('cron');