[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
Wed Feb 4 14:17:25 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                               |
-------------------------------------------------+-------------------------
Changes (by huzaifaalmesbah):

 * keywords:  has-patch has-unit-tests has-test-info needs-testing 2nd-
     opinion => has-patch has-unit-tests has-test-info 2nd-opinion


Comment:

 == Patch Testing Report

 Patch Tested: https://github.com/WordPress/wordpress-develop/pull/9914

 === Environment
 - WordPress: 7.0-alpha-61215-src
 - PHP: 8.2.30
 - Server: nginx/1.29.4
 - Database: mysqli (Server: 9.5.0 / Client: mysqlnd 8.2.30)
 - Browser: Chrome 144.0.0.0
 - OS: macOS
 - Theme: Twenty Twenty-Five 1.4
 - MU Plugins:
   * Ticket 63987 1.0 (reproduction plugin)
 - Plugins:
   * Classic Editor 1.6.7
   * Hello Dolly 1.7.2
   * Test Reports 1.2.1

 === Steps taken
 1. Activated the Ticket 63987 reproduction plugin.
 2. Plugin injected two cron events:
    - timestamp 0 (bug case)
    - future timestamp (control case)
 3. Called wp_get_scheduled_event() for both timestamps.
 4. Before applying the patch, the timestamp 0 event returned bool(false)
 while the future event returned a valid object.
 5. Applied PR patch.
 6. Re-tested using the same steps; both timestamp 0 and future timestamps
 now return valid event objects.
 7. ✅ Patch is solving the problem

 === Expected result
 - wp_get_scheduled_event() should return the scheduled event object for
 any valid timestamp, including 0.
 - Timestamp 0 should not be treated as missing or falsy.
 - Both events should consistently return an stdClass object.

 === Additional Notes
 - Root cause was the conditional `if ( ! $timestamp )`, which treats 0 as
 false in PHP.
 - Patch updates this to `if ( null === $timestamp )`, correctly
 distinguishing between null and 0.
 - Verified no regressions in normal cron behavior.
 - Fix is minimal, safe, and works as expected.


 === Screenshots/Screencast with results
  Before patch and after patch: https://files.catbox.moe/uby6vr.mp4

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


More information about the wp-trac mailing list