[wp-trac] [WordPress Trac] #63830: Event system breaks when an event is scheduled during processing of a queue of more than one events
WordPress Trac
noreply at wordpress.org
Fri Aug 15 17:06:24 UTC 2025
#63830: Event system breaks when an event is scheduled during processing of a queue
of more than one events
--------------------------+-----------------------------
Reporter: madhazelnut | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cron API | Version: 6.8.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
We've had instances of events "disappearing" and traced it down to them
not being registered in the event system when a queue of more than one
event is being processed in parallel.
== To Reproduce
=== Step 1
Add the following code (in a must-use plugin, for example):
{{{#!php
<?php
add_action('my_regular_task', function($param) {
// do something meaningful
});
add_action('my_long_task', function() {
echo 'Started my_long_task. Maybe request an HTTP page now?', "\n";
for($i=0;$i<5; $i++) {
sleep(2);
echo "\t", 'Zzz..', "\n";
}
echo 'Woa. Woke up!', "\n";
});
add_action('init', function() {
if (!defined('WP_CLI')) {
// This runs when requested via HTTP
$evt = wp_schedule_single_event(time()+1 , 'my_regular_task',
[uniqid()], true);
if (is_wp_error($evt)) {
die('Could not schedule event!'); // this makes sure the
event was indeed registered as scheduled..
}
}
});
}}}
=== Step 2
In a WPCLI session:
{{{#!bash
wp cron event schedule my_long_task --0=foo
wp cron event schedule my_long_task --0=bar
wp cron event run --due-now
}}}
While the two events are being processed perform one HTTP request to any
front end page in your browser (to schedule the regular task).
=== Step 3
{{{#!bash
wp cron event list
}}}
== Expected result
On step 3 we see the list of events containing one instance of
`my_regular_task`.
== Actual result
The event list does NOT contain `my_regular_task`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63830>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list