Avoid an undefined index notice in wp_reschedule_event().

props paulschreiber.
fixes #29077.
Built from https://develop.svn.wordpress.org/trunk@29349


git-svn-id: http://core.svn.wordpress.org/trunk@29126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-08-01 20:57:16 +00:00
parent 12e961cb61
commit 7753c3ff05

View File

@ -100,28 +100,32 @@ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
* @param array $args Optional. Arguments to pass to the hook's callback function.
* @return bool|null False on failure. Null when event is rescheduled.
*/
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
$key = md5(serialize($args));
$key = md5( serialize( $args ) );
$interval = 0;
// First we try to get it from the schedule
if ( 0 == $interval )
$interval = $schedules[$recurrence]['interval'];
if ( isset( $schedules[ $recurrence ] ) ) {
$interval = $schedules[ $recurrence ]['interval'];
}
// Now we try to get it from the saved interval in case the schedule disappears
if ( 0 == $interval )
$interval = $crons[$timestamp][$hook][$key]['interval'];
if ( 0 == $interval ) {
$interval = $crons[ $timestamp ][ $hook ][ $key ]['interval'];
}
// Now we assume something is wrong and fail to schedule
if ( 0 == $interval )
if ( 0 == $interval ) {
return false;
}
$now = time();
if ( $timestamp >= $now )
if ( $timestamp >= $now ) {
$timestamp = $now + $interval;
else
$timestamp = $now + ($interval - (($now - $timestamp) % $interval));
} else {
$timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) );
}
wp_schedule_event( $timestamp, $recurrence, $hook, $args );
}