WordPress.org

Make WordPress Core

Changeset 29349


Ignore:
Timestamp:
08/01/2014 08:56:11 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Avoid an undefined index notice in wp_reschedule_event().

props paulschreiber.
fixes #29077.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/cron.php

    r28781 r29349  
    101101 * @return bool|null False on failure. Null when event is rescheduled.
    102102 */
    103 function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
     103function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
    104104    $crons = _get_cron_array();
    105105    $schedules = wp_get_schedules();
    106     $key = md5(serialize($args));
     106    $key = md5( serialize( $args ) );
    107107    $interval = 0;
    108108
    109109    // First we try to get it from the schedule
    110     if ( 0 == $interval )
    111         $interval = $schedules[$recurrence]['interval'];
     110    if ( isset( $schedules[ $recurrence ] ) ) {
     111        $interval = $schedules[ $recurrence ]['interval'];
     112    }
    112113    // Now we try to get it from the saved interval in case the schedule disappears
    113     if ( 0 == $interval )
    114         $interval = $crons[$timestamp][$hook][$key]['interval'];
     114    if ( 0 == $interval ) {
     115        $interval = $crons[ $timestamp ][ $hook ][ $key ]['interval'];
     116    }
    115117    // Now we assume something is wrong and fail to schedule
    116     if ( 0 == $interval )
    117         return false;
     118    if ( 0 == $interval ) {
     119        return false;
     120    }
    118121
    119122    $now = time();
    120123
    121     if ( $timestamp >= $now )
     124    if ( $timestamp >= $now ) {
    122125        $timestamp = $now + $interval;
    123     else
    124         $timestamp = $now + ($interval - (($now - $timestamp) % $interval));
     126    } else {
     127        $timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) );
     128    }
    125129
    126130    wp_schedule_event( $timestamp, $recurrence, $hook, $args );
Note: See TracChangeset for help on using the changeset viewer.