From d01fa2e05232d241858ca54a26d02e285d178088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 18 Jun 2024 13:42:26 +0200 Subject: [PATCH] chore: Remove deprecated legacy search backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files/lib/AppInfo/Application.php | 5 -- core/Controller/SearchController.php | 47 ------------ lib/private/Search.php | 100 ------------------------- lib/private/Server.php | 15 ---- lib/public/ISearch.php | 51 ------------- lib/public/IServerContainer.php | 9 --- tests/lib/ServerTest.php | 2 - 7 files changed, 229 deletions(-) delete mode 100644 core/Controller/SearchController.php delete mode 100644 lib/private/Search.php delete mode 100644 lib/public/ISearch.php diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php index 5f57b2e2f34ba..a1b3feedaf9e3 100644 --- a/apps/files/lib/AppInfo/Application.php +++ b/apps/files/lib/AppInfo/Application.php @@ -118,7 +118,6 @@ public function register(IRegistrationContext $context): void { public function boot(IBootContext $context): void { $context->injectFn(Closure::fromCallable([$this, 'registerCollaboration'])); $context->injectFn([Listener::class, 'register']); - $context->injectFn(Closure::fromCallable([$this, 'registerSearchProvider'])); $this->registerTemplates(); $this->registerHooks(); } @@ -127,10 +126,6 @@ private function registerCollaboration(IProviderManager $providerManager): void $providerManager->registerResourceProvider(ResourceProvider::class); } - private function registerSearchProvider(ISearch $search): void { - $search->registerProvider(File::class, ['apps' => ['files']]); - } - private function registerTemplates(): void { $templateManager = \OC_Helper::getFileTemplateManager(); $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); diff --git a/core/Controller/SearchController.php b/core/Controller/SearchController.php deleted file mode 100644 index 1ca8dd5dae490..0000000000000 --- a/core/Controller/SearchController.php +++ /dev/null @@ -1,47 +0,0 @@ -searcher->searchPaged($query, $inApps, $page, $size); - - $results = array_filter($results, function (Result $result) { - if (json_encode($result, JSON_HEX_TAG) === false) { - $this->logger->warning("Skipping search result due to invalid encoding: {type: " . $result->type . ", id: " . $result->id . "}"); - return false; - } else { - return true; - } - }); - - return new JSONResponse($results); - } -} diff --git a/lib/private/Search.php b/lib/private/Search.php deleted file mode 100644 index d51a305b3312c..0000000000000 --- a/lib/private/Search.php +++ /dev/null @@ -1,100 +0,0 @@ -initProviders(); - $results = []; - foreach ($this->providers as $provider) { - if (! $provider->providesResultsFor($inApps)) { - continue; - } - if ($provider instanceof PagedProvider) { - $results = array_merge($results, $provider->searchPaged($query, $page, $size)); - } elseif ($provider instanceof Provider) { - $providerResults = $provider->search($query); - if ($size > 0) { - $slicedResults = array_slice($providerResults, ($page - 1) * $size, $size); - $results = array_merge($results, $slicedResults); - } else { - $results = array_merge($results, $providerResults); - } - } else { - \OCP\Server::get(LoggerInterface::class)->warning('Ignoring Unknown search provider', ['provider' => $provider]); - } - } - return $results; - } - - /** - * Remove all registered search providers - */ - public function clearProviders() { - $this->providers = []; - $this->registeredProviders = []; - } - - /** - * Remove one existing search provider - * @param string $provider class name of a OC\Search\Provider - */ - public function removeProvider($provider) { - $this->registeredProviders = array_filter( - $this->registeredProviders, - function ($element) use ($provider) { - return ($element['class'] != $provider); - } - ); - // force regeneration of providers on next search - $this->providers = []; - } - - /** - * Register a new search provider to search with - * @param string $class class name of a OC\Search\Provider - * @param array $options optional - */ - public function registerProvider($class, array $options = []) { - $this->registeredProviders[] = ['class' => $class, 'options' => $options]; - } - - /** - * Create instances of all the registered search providers - */ - private function initProviders() { - if (! empty($this->providers)) { - return; - } - foreach ($this->registeredProviders as $provider) { - $class = $provider['class']; - $options = $provider['options']; - $this->providers[] = new $class($options); - } - } -} diff --git a/lib/private/Server.php b/lib/private/Server.php index bcdf482f02d0e..b13369abe095b 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -184,7 +184,6 @@ use OCP\IPreview; use OCP\IRequest; use OCP\IRequestId; -use OCP\ISearch; use OCP\IServerContainer; use OCP\ISession; use OCP\ITagManager; @@ -762,10 +761,6 @@ public function __construct($webRoot, \OC\Config $config) { /** @deprecated 19.0.0 */ $this->registerDeprecatedAlias('Router', IRouter::class); - $this->registerAlias(ISearch::class, Search::class); - /** @deprecated 19.0.0 */ - $this->registerDeprecatedAlias('Search', ISearch::class); - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { $config = $c->get(\OCP\IConfig::class); if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) { @@ -1797,16 +1792,6 @@ public function getRouter() { return $this->get(IRouter::class); } - /** - * Returns a search instance - * - * @return ISearch - * @deprecated 20.0.0 - */ - public function getSearch() { - return $this->get(ISearch::class); - } - /** * Returns a SecureRandom instance * diff --git a/lib/public/ISearch.php b/lib/public/ISearch.php deleted file mode 100644 index 4279ee580c567..0000000000000 --- a/lib/public/ISearch.php +++ /dev/null @@ -1,51 +0,0 @@ -