Skip to content
Next Next commit
fix(search): Fix SearchComposer.php filtering logic
keep the $this->providers types

Test via ./occ config:app:set --value '["files","settings"]' --type array core unified_search.providers_allowed

should be part of 8e57004

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
  • Loading branch information
printminion-co committed Aug 11, 2025
commit 865041d04c7da9b8f93348d42c651b556ba4f7a1
18 changes: 10 additions & 8 deletions lib/private/Search/SearchComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private function loadLazyProviders(?string $targetProviderId = null): void {
}
}

$this->providers = $this->filterProviders($this->providers);
$this->filterProviders();

$this->loadFilters();
}
Expand Down Expand Up @@ -211,19 +211,21 @@ function (array $providerData) use ($route, $routeParameters) {

/**
* Filter providers based on 'unified_search.providers_allowed' core app config array
* @param array $providers
* @return array
* Will remove providers that are not in the allowed list
*/
private function filterProviders(array $providers): array {
private function filterProviders(): void {
$allowedProviders = $this->appConfig->getValueArray('core', 'unified_search.providers_allowed');

if (empty($allowedProviders)) {
return $providers;
return;
}

return array_values(array_filter($providers, function ($p) use ($allowedProviders) {
return in_array($p['id'], $allowedProviders);
}));
foreach (array_keys($this->providers) as $providerId) {
if (!in_array($providerId, $allowedProviders, true)) {
unset($this->providers[$providerId]);
unset($this->handlers[$providerId]);
}
}
}

private function fetchIcon(string $appId, string $providerId): string {
Expand Down