Fix analytics report download link not being sent (action scheduler blocking) (#50082)

* Reschedule jobs blocked by other delayed jobs

* Add changelog entry

* Comment next action time fallback

* Allow actions to be scheduled in the past

---------

Co-authored-by: Eason <eason.su.tw@gmail.com>
This commit is contained in:
Sakri Koskimies 2024-08-09 05:34:00 +03:00 committed by GitHub
parent 9d12459c44
commit 201f165600
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 16 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix rescheduling of actions that are blocked by other delayed actions

View File

@ -228,20 +228,7 @@ trait SchedulerTraits {
)
);
$next_job_schedule = null;
if ( is_array( $blocking_jobs ) ) {
foreach ( $blocking_jobs as $blocking_job ) {
$next_job_schedule = self::get_next_action_time( $blocking_job );
// Ensure that the next schedule is a DateTime (it can be null).
if ( is_a( $next_job_schedule, 'DateTime' ) ) {
return $blocking_job;
}
}
}
return false;
return reset( $blocking_jobs );
}
/**
@ -256,9 +243,15 @@ trait SchedulerTraits {
// or schedule to run now if no blocking jobs exist.
$blocking_job = static::get_next_blocking_job( $action_name );
if ( $blocking_job ) {
$after = new \DateTime();
$next_action_time = self::get_next_action_time( $blocking_job );
// Some actions, like single actions, don't have a next action time.
if ( ! is_a( $next_action_time, 'DateTime' ) ) {
$next_action_time = new \DateTime();
}
self::queue()->schedule_single(
self::get_next_action_time( $blocking_job )->getTimestamp() + 5,
$next_action_time->getTimestamp() + 5,
$action_hook,
$args,
static::$group