fix: Make sure array starts at 0 after array filter

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
pull/41271/head
Marcel Klehr 2023-11-10 11:13:54 +07:00
parent 017f136059
commit 2031fe17b4
1 changed files with 2 additions and 2 deletions

@ -282,14 +282,14 @@ class Manager implements IManager {
$preferences = json_decode($json, true);
if (isset($preferences[$task->getType()])) {
// If a preference for this task type is set, move the preferred provider to the start
$provider = current(array_filter($providers, fn ($provider) => $provider::class === $preferences[$task->getType()]));
$provider = current(array_values(array_filter($providers, fn ($provider) => $provider::class === $preferences[$task->getType()])));
if ($provider !== false) {
$providers = array_filter($providers, fn ($p) => $p !== $provider);
array_unshift($providers, $provider);
}
}
}
$providers = array_filter($providers, fn (IProvider $provider) => $task->canUseProvider($provider));
$providers = array_values(array_filter($providers, fn (IProvider $provider) => $task->canUseProvider($provider)));
return $providers;
}
}