Skip to content

Commit 101f58f

Browse files
committed
Handle bad interval for cron schedule
1 parent 63b3a8f commit 101f58f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/wp-includes/cron.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array(), $
359359
}
360360

361361
// Now we try to get it from the saved interval in case the schedule disappears.
362-
if ( 0 === $interval ) {
362+
if ( 0 === (int) $interval ) {
363363
$scheduled_event = wp_get_scheduled_event( $hook, $args, $timestamp );
364364

365365
if ( $scheduled_event && isset( $scheduled_event->interval ) ) {
@@ -417,11 +417,15 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array(), $
417417
}
418418

419419
// Now we assume something is wrong and fail to schedule.
420-
if ( 0 === $interval ) {
420+
if ( ! is_int( $interval ) || 0 <= $interval ) {
421421
if ( $wp_error ) {
422422
return new WP_Error(
423423
'invalid_schedule',
424-
__( 'Event schedule does not exist.' )
424+
sprintf(
425+
/* translators: %s is the interval encoded as JSON */
426+
__( 'Event schedule is invalid. Interval must be positive integer, but got: %s' ),
427+
wp_json_encode( $interval )
428+
)
425429
);
426430
}
427431

0 commit comments

Comments
 (0)