-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Handle bad interval for cron schedule #10619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 3 commits
101f58f
b39b67d
d023b9a
3bba3b9
76f3901
0184a4d
063c21e
662315d
cda5935
c6efb67
d1c3ba6
0fae040
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -359,7 +359,7 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array(), $ | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // Now we try to get it from the saved interval in case the schedule disappears. | ||||||||||||||||||
| if ( 0 === $interval ) { | ||||||||||||||||||
| if ( 0 === (int) $interval ) { | ||||||||||||||||||
| $scheduled_event = wp_get_scheduled_event( $hook, $args, $timestamp ); | ||||||||||||||||||
|
|
||||||||||||||||||
| if ( $scheduled_event && isset( $scheduled_event->interval ) ) { | ||||||||||||||||||
|
|
@@ -417,11 +417,15 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array(), $ | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // Now we assume something is wrong and fail to schedule. | ||||||||||||||||||
| if ( 0 === $interval ) { | ||||||||||||||||||
| if ( ! is_int( $interval ) || $interval <= 0 ) { | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Matches the behaivour of the existing check in |
||||||||||||||||||
| if ( $wp_error ) { | ||||||||||||||||||
| return new WP_Error( | ||||||||||||||||||
| 'invalid_schedule', | ||||||||||||||||||
| __( 'Event schedule does not exist.' ) | ||||||||||||||||||
| sprintf( | ||||||||||||||||||
| /* translators: %s is the interval encoded as JSON */ | ||||||||||||||||||
| __( 'Event schedule is invalid. Interval must be positive integer, but got: %s' ), | ||||||||||||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would be good if a named schedule is used, ie if the code doesn't fall back to wordpress-develop/src/wp-includes/cron.php Lines 361 to 368 in 8b0250c
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not like 063c21e? |
||||||||||||||||||
| wp_json_encode( $interval ) | ||||||||||||||||||
| ) | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It took me a couple of reads to understand what this is trying to tell me. The interval is an internal implementation detail that's not used by anyone calling this function, so I'm not sure it's an actionable message. Is it possible to reliably distinguish between a schedule that doesn't exist and a schedule that exists but has an invalid interval? If so, let's use two separate error messages, one for each case, then make each error message clearer.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about c6efb67? |
||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.