WordPress.org

Make WordPress Core

Ticket #33475: 33475.2.diff

File 33475.2.diff, 2.2 KB (added by SergeyBiryukov, 6 years ago)
  • src/wp-includes/cron.php

     
    1818 * @param int $timestamp Timestamp for when to run the event.
    1919 * @param string $hook Action hook to execute when cron is run.
    2020 * @param array $args Optional. Arguments to pass to the hook's callback function.
    21  * @return void|false
     21 * @return void|false False when does not schedule event.
    2222 */
    2323function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
    24         // don't schedule a duplicate if there's already an identical event due within 10 minutes of it
     24        // Make sure timestamp is a positive integer
     25        if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
     26                return false;
     27        }
     28
     29        // Don't schedule a duplicate if there's already an identical event due within 10 minutes of it
    2530        $next = wp_next_scheduled($hook, $args);
    2631        if ( $next && abs( $next - $timestamp ) <= 10 * MINUTE_IN_SECONDS ) {
    27                 return;
     32                return false;
    2833        }
    2934
    3035        $crons = _get_cron_array();
     
    7075 * @return false|void False when does not schedule event.
    7176 */
    7277function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
     78        // Make sure timestamp is a positive integer
     79        if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
     80                return false;
     81        }
     82
    7383        $crons = _get_cron_array();
    7484        $schedules = wp_get_schedules();
    7585
     
    103113 * @return false|void False when does not schedule event.
    104114 */
    105115function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
     116        // Make sure timestamp is a positive integer
     117        if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
     118                return false;
     119        }
     120
    106121        $crons = _get_cron_array();
    107122        $schedules = wp_get_schedules();
    108123        $key = md5( serialize( $args ) );
     
    148163 * as those used when originally scheduling the event.
    149164 */
    150165function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
     166        // Make sure timestamp is a positive integer
     167        if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
     168                return false;
     169        }
     170
    151171        $crons = _get_cron_array();
    152172        $key = md5(serialize($args));
    153173        unset( $crons[$timestamp][$hook][$key] );