File tree 1 file changed +8
-3
lines changed
lib/private/TaskProcessing
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ class Manager implements IManager {
80
80
81
81
private IAppData $ appData ;
82
82
private ?array $ preferences = null ;
83
+ private ?array $ providersById = null ;
83
84
private ICache $ cache ;
84
85
private ICache $ distributedCache ;
85
86
@@ -717,9 +718,13 @@ public function getPreferredProvider(string $taskTypeId) {
717
718
718
719
$ providers = $ this ->getProviders ();
719
720
if (isset ($ this ->preferences [$ taskTypeId ])) {
720
- $ provider = current (array_values (array_filter ($ providers , fn ($ provider ) => $ provider ->getId () === $ this ->preferences [$ taskTypeId ])));
721
- if ($ provider !== false ) {
722
- return $ provider ;
721
+ $ providersById = $ this ->providersById ?? array_reduce ($ providers , static function (array $ carry , IProvider $ provider ) {
722
+ $ carry [$ provider ->getId ()] = $ provider ;
723
+ return $ carry ;
724
+ }, []);
725
+ $ this ->providersById = $ providersById ;
726
+ if (isset ($ providersById [$ this ->preferences [$ taskTypeId ]])) {
727
+ return $ providersById [$ this ->preferences [$ taskTypeId ]];
723
728
}
724
729
}
725
730
// By default, use the first available provider
You can’t perform that action at this time.
0 commit comments