[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
Sat Mar 14 06:28:06 UTC 2026


#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:  7.0
Component:  Cron API                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests has-test-   |     Focuses:
  info 2nd-opinion                               |
-------------------------------------------------+-------------------------

Comment (by alexodiy):

 Hey everyone, I tested PR [https://github.com/WordPress/wordpress-
 develop/pull/9914 #9914] on PHP 8.5.1 (Windows) against trunk r61991 and
 can confirm the fix works as expected.

 I injected a cron event at timestamp `0` alongside a regular future event,
 then tried to retrieve both with `wp_get_scheduled_event()`.

 '''Before the patch:''' the event at timestamp 0 returns `false` because
 `if ( ! $timestamp )` treats `0` as falsy. The future event works fine.

 '''After the patch:''' changing to `if ( null === $timestamp )` fixes it.
 The event at timestamp 0 is now correctly returned as an object, and the
 "get next event" logic (when no timestamp is passed) still works as
 before.

 I also checked a few edge cases just to be safe:

 ||= Scenario =||= Before Patch =||= After Patch =||
 || Explicit timestamp 0 || `false` (bug) || Event object (correct) ||
 || Future timestamp || Event object || Event object ||
 || Non-existent hook at 0 || `false` || `false` (correct) ||
 || Null timestamp (get next) || Works || Works ||

 No regressions on my end. Clean and minimal fix. +1 for commit.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63987#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list