[wp-trac] [WordPress Trac] #64315: Running `_wp_cron()` on shutdown breaks `ALTERNATE_WP_CRON`
WordPress Trac
noreply at wordpress.org
Thu Nov 27 00:14:54 UTC 2025
#64315: Running `_wp_cron()` on shutdown breaks `ALTERNATE_WP_CRON`
--------------------------+-----------------------------
Reporter: karl94 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cron API | Version: trunk
Severity: major | Keywords:
Focuses: |
--------------------------+-----------------------------
In #63858, [60925] moved cron spawing from the `wp_loaded` hook to
`shutdown`.
While this is fine for usual cron spawning via `wp_remote_post()`, the
alternative cron behavior doesn't work properly after this change.
`ALTERNATE_WP_CRON` is an alternative cron spawning method: it's meant to
be used in environments where HTTP loopback request cannot be used and
works by redirecting the client to the same URL with just an extra
`doing_wp_cron` query param. This way, on the first request (the one that
outputs the redirect) crons are executed "in background" while the client
follows the redirect and loads the URL requested.
The issue is that by moving `_wp_cron()` execution to shutdown the
redirect can't be performed as output already started (and triggers the
''Cannot modify header information - headers already sent'' warning).
https://github.com/WordPress/wordpress-
develop/blob/217d39aa50c5e15584a921c3e58eb104f0d96eed/src/wp-
includes/cron.php#L918
Furthermore, `wp-cron.php` [https://github.com/WordPress/wordpress-
develop/blob/217d39aa50c5e15584a921c3e58eb104f0d96eed/src/wp-cron.php#L205
may call] `die()`, which would then terminate execution preventing other
callbacks attached to the `shutdown` hook to run.
I think that on `ALTERNATE_WP_CRON` the previous behavior should be
restored: the `wp_loaded` hook should be used instead of `shutdown`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64315>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list