[wp-trac] [WordPress Trac] #63987: wp_get_scheduled_event() incorrectly returns false for cron events scheduled with a timestamp of 0.
WordPress Trac
noreply at wordpress.org
Mon Oct 6 20:27:34 UTC 2025
#63987: wp_get_scheduled_event() incorrectly returns false for cron events
scheduled with a timestamp of 0.
-------------------------------------------------+-------------------------
Reporter: codekraft | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.9
Component: Cron API | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has-test- | Focuses:
info needs-testing 2nd-opinion |
-------------------------------------------------+-------------------------
Changes (by mindctrl):
* keywords: has-patch has-unit-tests has-test-info needs-testing => has-
patch has-unit-tests has-test-info needs-testing 2nd-opinion
Comment:
It appears this behavior is intentional, since the helper functions for
scheduling events return false and/or a `WP_Error` object when a timestamp
of `0` is provided. (`wp_schedule_event`, `wp_schedule_single_event`,
`wp_reschedule_event`, `wp_unschedule_event`).
[https://github.com/WordPress/wordpress-
develop/blob/fe2b33f27b8eef2b42771414a9464a3508cbca3a/src/wp-
includes/cron.php#L41 / Example]
If using `wp_schedule_event()` or related, this bug doesn't really exist
because the `0` timestamp is considered invalid and it won't be added to
the cron array.
`0` is a valid timestamp, but is there a use case for scheduling events at
0? What would be the purpose of scheduling at 0, instead of say `now()` or
even `1`?
In the original ticket, the example uses `_set_cron_array()`, which is
marked as `private` in the phpdocs, like many/most functions in WP that
begin with the `_` character.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63987#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list