Skip to content

Commit

Permalink
fix(taskprocessing): fix condition to reschedule SynchronousBackgroun…
Browse files Browse the repository at this point in the history
…dJob

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
  • Loading branch information
julien-nc committed Aug 27, 2024
1 parent c1ed256 commit 4b849ef
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/private/TaskProcessing/SynchronousBackgroundJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,21 @@ protected function run($argument) {
}
}

// check if this job needs to be scheduled again:
// if there is at least one preferred synchronous provider that has a scheduled task
$synchronousProviders = array_filter($providers, fn ($provider) =>
$provider instanceof ISynchronousProvider);
$taskTypes = array_values(array_map(fn ($provider) =>
$provider->getTaskTypeId(),
$synchronousProviders
));
$synchronousPreferredProviders = array_filter($synchronousProviders, function ($provider) {
$taskTypeId = $provider->getTaskTypeId();
$preferredProvider = $this->taskProcessingManager->getPreferredProvider($taskTypeId);
return $provider->getId() === $preferredProvider->getId();
});
$taskTypes = array_values(
array_map(
fn ($provider) => $provider->getTaskTypeId(),
$synchronousPreferredProviders
)
);
$taskTypesWithTasks = array_filter($taskTypes, function ($taskType) {
try {
$this->taskProcessingManager->getNextScheduledTask([$taskType]);
Expand Down

0 comments on commit 4b849ef

Please sign in to comment.