Make WordPress Core

Ticket #37769: 37769.patch

File 37769.patch, 8.5 KB (added by johnbillion, 9 years ago)
  • src/wp-includes/cron.php

     
    11<?php
    22/**
    3  * WordPress CRON API
     3 * WordPress Cron API
    44 *
    55 * @package WordPress
    66 */
    77
    88/**
    9  * Schedules a hook to run only once.
     9 * Schedules an event to run only once.
    1010 *
    11  * Schedules a hook which will be executed once by the WordPress actions core at
     11 * Schedules an event which will execute once by the WordPress actions core at
    1212 * a time which you specify. The action will fire off when someone visits your
    1313 * WordPress site, if the schedule time has passed.
    1414 *
    1515 * Note that scheduling an event to occur within 10 minutes of an existing event
    16  * with the same action hook will be ignored, unless you pass unique `$args` values
     16 * with the same action hook will be ignored unless you pass unique `$args` values
    1717 * for each scheduled event.
    1818 *
    1919 * @since 2.1.0
    2020 * @link https://codex.wordpress.org/Function_Reference/wp_schedule_single_event
    2121 *
    22  * @param int $timestamp Timestamp for when to run the event.
    23  * @param string $hook Action hook to execute when cron is run.
     22 * @param int $timestamp Unix timestamp (UTC) for when to run the event.
     23 * @param string $hook Action hook to execute when event is run.
    2424 * @param array $args Optional. Arguments to pass to the hook's callback function.
    25  * @return false|void False when an event is not scheduled.
     25 * @return false|void False if the event does not get scheduled.
    2626 */
    2727function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
    2828        // Make sure timestamp is a positive integer
     
    4343         *
    4444         * @since 3.1.0
    4545         *
    46          * @param object $event An object containing an event's data.
     46         * @param stdClass $event {
     47         *     An object containing an event's data.
     48         *
     49         *     @type string       $hook      Action hook to execute when event is run.
     50         *     @type int          $timestamp Unix timestamp (UTC) for when to run the event.
     51         *     @type string|false $schedule  How often the event should recur. See `wp_get_schedules()`.
     52         *     @type array        $args      Arguments to pass to the hook's callback function.
     53         * }
    4754         */
    4855        $event = apply_filters( 'schedule_event', $event );
    4956
     
    5966}
    6067
    6168/**
    62  * Schedule a periodic event.
     69 * Schedule a recurring event.
    6370 *
    6471 * Schedules a hook which will be executed by the WordPress actions core on a
    6572 * specific interval, specified by you. The action will trigger when someone
    6673 * visits your WordPress site, if the scheduled time has passed.
    6774 *
    68  * Valid values for the recurrence are hourly, daily and twicedaily. These can
     75 * Valid values for the recurrence are hourly, daily, and twicedaily. These can
    6976 * be extended using the {@see 'cron_schedules'} filter in wp_get_schedules().
    7077 *
    7178 * Use wp_next_scheduled() to prevent duplicates
    7279 *
    7380 * @since 2.1.0
    7481 *
    75  * @param int $timestamp Timestamp for when to run the event.
     82 * @param int $timestamp Unix timestamp (UTC) for when to run the event.
    7683 * @param string $recurrence How often the event should recur.
    77  * @param string $hook Action hook to execute when cron is run.
     84 * @param string $hook Action hook to execute when event is run.
    7885 * @param array $args Optional. Arguments to pass to the hook's callback function.
    79  * @return false|void False when an event is not scheduled.
     86 * @return false|void False if the event does not get scheduled.
    8087 */
    8188function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
    8289        // Make sure timestamp is a positive integer
     
    110117 *
    111118 * @since 2.1.0
    112119 *
    113  * @param int $timestamp Timestamp for when to run the event.
     120 * @param int $timestamp Unix timestamp (UTC) for when to run the event.
    114121 * @param string $recurrence How often the event should recur.
    115  * @param string $hook Action hook to execute when cron is run.
     122 * @param string $hook Action hook to execute when event is run.
    116123 * @param array $args Optional. Arguments to pass to the hook's callback function.
    117  * @return false|void False when an event is not scheduled.
     124 * @return false|void False if the event does not get rescheduled.
    118125 */
    119126function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
    120127        // Make sure timestamp is a positive integer
     
    152159}
    153160
    154161/**
    155  * Unschedule a previously scheduled cron job.
     162 * Unschedule a previously scheduled event.
    156163 *
    157  * The $timestamp and $hook parameters are required, so that the event can be
     164 * The $timestamp and $hook parameters are required so that the event can be
    158165 * identified.
    159166 *
    160167 * @since 2.1.0
    161168 *
    162  * @param int $timestamp Timestamp for when to run the event.
     169 * @param int $timestamp Unix timestamp (UTC) for when to run the event.
    163170 * @param string $hook Action hook, the execution of which will be unscheduled.
    164171 * @param array $args Arguments to pass to the hook's callback function.
    165172 * Although not passed to a callback function, these arguments are used
    166173 * to uniquely identify the scheduled event, so they should be the same
    167174 * as those used when originally scheduling the event.
    168  * @return false|void False when an event is not unscheduled.
     175 * @return false|void False if the event does not get unscheduled.
    169176 */
    170177function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
    171178        // Make sure timestamp is a positive integer
     
    184191}
    185192
    186193/**
    187  * Unschedule all cron jobs attached to a specific hook.
     194 * Unschedule all events attached to the specified hook.
    188195 *
    189196 * @since 2.1.0
    190197 *
    191198 * @param string $hook Action hook, the execution of which will be unscheduled.
    192  * @param array $args Optional. Arguments that were to be pass to the hook's callback function.
     199 * @param array $args Optional. Arguments that were to be passed to the hook's callback function.
    193200 */
    194201function wp_clear_scheduled_hook( $hook, $args = array() ) {
    195202        // Backward compatibility
     
    215222}
    216223
    217224/**
    218  * Retrieve the next timestamp for a cron event.
     225 * Retrieve the next timestamp for an event.
    219226 *
    220227 * @since 2.1.0
    221228 *
    222  * @param string $hook Action hook to execute when cron is run.
     229 * @param string $hook Action hook to execute when event is run.
    223230 * @param array $args Optional. Arguments to pass to the hook's callback function.
    224  * @return false|int The UNIX timestamp of the next time the scheduled event will occur.
     231 * @return false|int The Unix timestamp of the next time the scheduled event will occur.
    225232 */
    226233function wp_next_scheduled( $hook, $args = array() ) {
    227234        $crons = _get_cron_array();
     
    240247 *
    241248 * @since 2.1.0
    242249 *
    243  * @param int $gmt_time Optional. Unix timestamp. Default 0 (current time is used).
     250 * @param int $gmt_time Optional. Unix timestamp (UTC). Default 0 (current time is used).
    244251 */
    245252function spawn_cron( $gmt_time = 0 ) {
    246253        if ( ! $gmt_time )
     
    250257                return;
    251258
    252259        /*
    253          * Get the cron lock, which is a unix timestamp of when the last cron was spawned
     260         * Get the cron lock, which is a Unix timestamp of when the last cron was spawned
    254261         * and has not finished running.
    255262         *
    256263         * Multiple processes on multiple web servers can run this code concurrently,
     
    364371}
    365372
    366373/**
    367  * Retrieve supported and filtered Cron recurrences.
     374 * Retrieve supported event recurrence schedules.
    368375 *
    369  * The supported recurrences are 'hourly' and 'daily'. A plugin may add more by
    370  * hooking into the {@see 'cron_schedules'} filter. The filter accepts an array of
    371  * arrays. The outer array has a key that is the name of the schedule or for
     376 * The default supported recurrences are 'hourly', 'twicedaily', and 'daily'. A plugin may
     377 * add more by hooking into the {@see 'cron_schedules'} filter. The filter accepts an array
     378 * of arrays. The outer array has a key that is the name of the schedule or for
    372379 * example 'weekly'. The value is an array with two keys, one is 'interval' and
    373380 * the other is 'display'.
    374381 *
     
    410417}
    411418
    412419/**
    413  * Retrieve Cron schedule for hook with arguments.
     420 * Retrieve the recurrence schedule for an event.
     421 *
     422 * @see wp_get_schedules() for available schedules.
    414423 *
    415424 * @since 2.1.0
    416425 *
    417  * @param string $hook Action hook to execute when cron is run.
    418  * @param array $args Optional. Arguments to pass to the hook's callback function.
    419  * @return string|false False, if no schedule. Schedule on success.
     426 * @param string $hook Action hook to identify the event.
     427 * @param array $args Optional. Arguments passed to the event's callback function.
     428 * @return string|false False, if no schedule. Schedule name on success.
    420429 */
    421430function wp_get_schedule($hook, $args = array()) {
    422431        $crons = _get_cron_array();