From 9d6a770c6c68528269fa2d0fb783a1bee7a9c330 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 21 Sep 2026 10:05:07 -0100 Subject: [PATCH] fix(globalscale): ignore lookupserver if empty config Signed-off-by: Maxence Lange --- lib/private/Collaboration/Collaborators/Search.php | 5 +++++ lib/private/Server.php | 2 +- tests/lib/Collaboration/Collaborators/SearchResultTest.php | 3 ++- tests/lib/Collaboration/Collaborators/SearchTest.php | 6 ++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php index 0114eae2d62da..4d8bfa9ee71f8 100644 --- a/lib/private/Collaboration/Collaborators/Search.php +++ b/lib/private/Collaboration/Collaborators/Search.php @@ -13,6 +13,7 @@ use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IConfig; use OCP\IContainer; use OCP\Share\IShare; @@ -23,6 +24,7 @@ class Search implements ISearch { public function __construct( private readonly IContainer $container, private readonly IEventDispatcher $eventDispatcher, + private readonly IConfig $config, ) { } @@ -41,6 +43,9 @@ public function filteredSearch(string $search, array $shareTypes, bool $lookup, $searchResult = new SearchResult(); + // confirm lookup server is not empty + $lookup = $lookup && !empty($this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com')); + foreach ($shareTypes as $type) { if (!isset($this->pluginList[$type])) { continue; diff --git a/lib/private/Server.php b/lib/private/Server.php index 9e9e1ea0b5114..4426021a3b1ff 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -981,7 +981,7 @@ public function __construct( $this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class); $this->registerService(ISearch::class, static function (Server $c): ISearch { - $instance = new Search($c, $c->get(IEventDispatcher::class)); + $instance = new Search($c, $c->get(IEventDispatcher::class), $c->get(IConfig::class)); // register default plugins $instance->registerPlugin(['shareType' => IShare::TYPE_USER, 'class' => UserPlugin::class]); diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php index 05c4692ed70cd..b179d83610e7d 100644 --- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php +++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php @@ -12,6 +12,7 @@ use OCP\Collaboration\Collaborators\ISearch; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IConfig; use OCP\IContainer; use Test\TestCase; @@ -27,7 +28,7 @@ protected function setUp(): void { $this->container = $this->createMock(IContainer::class); - $this->search = new Search($this->container, $this->createMock(IEventDispatcher::class)); + $this->search = new Search($this->container, $this->createMock(IEventDispatcher::class), $this->createMock(IConfig::class)); } public static function dataAddResultSet(): array { diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php index c8e91949356bf..cdf044fa84fb1 100644 --- a/tests/lib/Collaboration/Collaborators/SearchTest.php +++ b/tests/lib/Collaboration/Collaborators/SearchTest.php @@ -15,6 +15,7 @@ use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IConfig; use OCP\IContainer; use OCP\Share\IShare; use PHPUnit\Framework\MockObject\MockObject; @@ -23,6 +24,7 @@ class SearchTest extends TestCase { protected IContainer&MockObject $container; protected IEventDispatcher&MockObject $eventDispatcher; + protected IConfig&MockObject $config; protected Search $search; #[\Override] @@ -31,8 +33,8 @@ protected function setUp(): void { $this->container = $this->createMock(IContainer::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); - - $this->search = new Search($this->container, $this->eventDispatcher); + $this->config = $this->createMock(IConfig::class); + $this->search = new Search($this->container, $this->eventDispatcher, $this->config); } #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchSharees')]