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:
parent
12e961cb61
commit
7753c3ff05
|
@ -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.
|
* @param array $args Optional. Arguments to pass to the hook's callback function.
|
||||||
* @return bool|null False on failure. Null when event is rescheduled.
|
* @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();
|
$crons = _get_cron_array();
|
||||||
$schedules = wp_get_schedules();
|
$schedules = wp_get_schedules();
|
||||||
$key = md5(serialize($args));
|
$key = md5( serialize( $args ) );
|
||||||
$interval = 0;
|
$interval = 0;
|
||||||
|
|
||||||
// First we try to get it from the schedule
|
// First we try to get it from the schedule
|
||||||
if ( 0 == $interval )
|
if ( isset( $schedules[ $recurrence ] ) ) {
|
||||||
$interval = $schedules[$recurrence]['interval'];
|
$interval = $schedules[ $recurrence ]['interval'];
|
||||||
|
}
|
||||||
// Now we try to get it from the saved interval in case the schedule disappears
|
// Now we try to get it from the saved interval in case the schedule disappears
|
||||||
if ( 0 == $interval )
|
if ( 0 == $interval ) {
|
||||||
$interval = $crons[$timestamp][$hook][$key]['interval'];
|
$interval = $crons[ $timestamp ][ $hook ][ $key ]['interval'];
|
||||||
|
}
|
||||||
// Now we assume something is wrong and fail to schedule
|
// Now we assume something is wrong and fail to schedule
|
||||||
if ( 0 == $interval )
|
if ( 0 == $interval ) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
|
|
||||||
if ( $timestamp >= $now )
|
if ( $timestamp >= $now ) {
|
||||||
$timestamp = $now + $interval;
|
$timestamp = $now + $interval;
|
||||||
else
|
} else {
|
||||||
$timestamp = $now + ($interval - (($now - $timestamp) % $interval));
|
$timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) );
|
||||||
|
}
|
||||||
|
|
||||||
wp_schedule_event( $timestamp, $recurrence, $hook, $args );
|
wp_schedule_event( $timestamp, $recurrence, $hook, $args );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue