diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php index 15b576938d2..f0a7b063c9a 100644 --- a/apps/comments/lib/AppInfo/Application.php +++ b/apps/comments/lib/AppInfo/Application.php @@ -13,7 +13,6 @@ use OCA\Comments\Listener\LoadSidebarScripts; use OCA\Comments\MaxAutoCompleteResultsInitialState; use OCA\Comments\Notification\Notifier; use OCA\Comments\Search\CommentsSearchProvider; -use OCA\Comments\Search\LegacyProvider; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadSidebar; use OCP\AppFramework\App; @@ -22,7 +21,6 @@ use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Comments\CommentsEntityEvent; use OCP\Comments\CommentsEvent; -use OCP\ISearch; class Application extends App implements IBootstrap { public const APP_ID = 'comments'; @@ -59,6 +57,5 @@ class Application extends App implements IBootstrap { } public function boot(IBootContext $context): void { - $context->getServerContainer()->get(ISearch::class)->registerProvider(LegacyProvider::class, ['apps' => ['files']]); } } diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php index b4fd04c9fbc..de0542c8ad3 100644 --- a/apps/files/lib/AppInfo/Application.php +++ b/apps/files/lib/AppInfo/Application.php @@ -9,7 +9,6 @@ declare(strict_types=1); namespace OCA\Files\AppInfo; use Closure; -use OC\Search\Provider\File; use OCA\Files\Capabilities; use OCA\Files\Collaboration\Resources\Listener; use OCA\Files\Collaboration\Resources\ResourceProvider; @@ -45,7 +44,6 @@ use OCP\Files\Events\Node\NodeCopiedEvent; use OCP\IConfig; use OCP\IPreview; use OCP\IRequest; -use OCP\ISearch; use OCP\IServerContainer; use OCP\ITagManager; use OCP\IUserSession; @@ -127,7 +125,6 @@ class Application extends App implements IBootstrap { 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(); } @@ -136,10 +133,6 @@ class Application extends App implements IBootstrap { $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/build/integration/comments_features/comments-search.feature b/build/integration/comments_features/comments-search.feature deleted file mode 100644 index 19802dd2182..00000000000 --- a/build/integration/comments_features/comments-search.feature +++ /dev/null @@ -1,273 +0,0 @@ -# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later -Feature: comments-search - - Scenario: Search my own comment on a file belonging to myself - Given user "user0" exists - And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt" - And "user0" posts a comment with content "My first comment" on the file named "/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "first" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | My first comment | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | My first comment | - - Scenario: Search my own comment on a file shared by someone with me - Given user "user0" exists - And user "user1" exists - And User "user1" uploads file "data/textfile.txt" to "/sharedFileToComment.txt" - And as "user1" creating a share with - | path | sharedFileToComment.txt | - | shareWith | user0 | - | shareType | 0 | - And user "user0" accepts last share - And "user0" posts a comment with content "My first comment" on the file named "/sharedFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "first" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | My first comment | - | authorId | user0 | - | authorName | user0 | - | path | sharedFileToComment.txt | - | fileName | sharedFileToComment.txt | - | name | My first comment | - - Scenario: Search other user's comment on a file shared by me - Given user "user0" exists - And user "user1" exists - And User "user0" uploads file "data/textfile.txt" to "/mySharedFileToComment.txt" - And as "user0" creating a share with - | path | mySharedFileToComment.txt | - | shareWith | user1 | - | shareType | 0 | - And user "user1" accepts last share - And "user1" posts a comment with content "Other's first comment" on the file named "/mySharedFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "first" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | Other's first comment | - | authorId | user1 | - | authorName | user1 | - | path | mySharedFileToComment.txt | - | fileName | mySharedFileToComment.txt | - | name | Other's first comment | - - Scenario: Search other user's comment on a file shared by someone with me - Given user "user0" exists - And user "user1" exists - And User "user1" uploads file "data/textfile.txt" to "/sharedFileToComment.txt" - And as "user1" creating a share with - | path | sharedFileToComment.txt | - | shareWith | user0 | - | shareType | 0 | - And user "user0" accepts last share - And "user1" posts a comment with content "Other's first comment" on the file named "/sharedFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "first" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | Other's first comment | - | authorId | user1 | - | authorName | user1 | - | path | sharedFileToComment.txt | - | fileName | sharedFileToComment.txt | - | name | Other's first comment | - - Scenario: Search several comments on a file belonging to myself - Given user "user0" exists - And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt" - And "user0" posts a comment with content "My first comment to be found" on the file named "/myFileToComment.txt" it should return "201" - And "user0" posts a comment with content "The second comment should not be found" on the file named "/myFileToComment.txt" it should return "201" - And "user0" posts a comment with content "My third comment to be found" on the file named "/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "comment to be found" in app "files" - Then the list of search results has "2" results - And search result "0" contains - | type | comment | - | comment | My third comment to be found | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | My third comment to be found | - And search result "1" contains - | type | comment | - | comment | My first comment to be found | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | My first comment to be found | - - Scenario: Search comment with a large message ellipsized on the right - Given user "user0" exists - And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt" - And "user0" posts a comment with content "A very verbose message that is meant to be used to test the ellipsized message returned when searching for long comments" on the file named "/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "verbose" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | A very verbose message that is meant to… | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | A very verbose message that is meant to be used to test the ellipsized message returned when searching for long comments | - - Scenario: Search comment with a large message ellipsized on the left - Given user "user0" exists - And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt" - And "user0" posts a comment with content "A very verbose message that is meant to be used to test the ellipsized message returned when searching for long comments" on the file named "/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "searching" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | …ed message returned when searching for long comments | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | A very verbose message that is meant to be used to test the ellipsized message returned when searching for long comments | - - Scenario: Search comment with a large message ellipsized on both ends - Given user "user0" exists - And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt" - And "user0" posts a comment with content "A very verbose message that is meant to be used to test the ellipsized message returned when searching for long comments" on the file named "/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "ellipsized" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | …t to be used to test the ellipsized message returned when se… | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | A very verbose message that is meant to be used to test the ellipsized message returned when searching for long comments | - - Scenario: Search comment on a file in a subfolder - Given user "user0" exists - And user "user0" created a folder "/subfolder" - And User "user0" uploads file "data/textfile.txt" to "/subfolder/myFileToComment.txt" - And "user0" posts a comment with content "My first comment" on the file named "/subfolder/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "first" in app "files" - Then the list of search results has "1" results - And search result "0" contains - | type | comment | - | comment | My first comment | - | authorId | user0 | - | authorName | user0 | - | path | subfolder/myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | My first comment | - - Scenario: Search several comments - Given user "user0" exists - And user "user1" exists - And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt" - And User "user0" uploads file "data/textfile.txt" to "/mySharedFileToComment.txt" - And as "user0" creating a share with - | path | mySharedFileToComment.txt | - | shareWith | user1 | - | shareType | 0 | - And user "user1" accepts last share - And User "user1" uploads file "data/textfile.txt" to "/sharedFileToComment.txt" - And as "user1" creating a share with - | path | sharedFileToComment.txt | - | shareWith | user0 | - | shareType | 0 | - And user "user0" accepts last share - And "user0" posts a comment with content "My first comment to be found" on the file named "/myFileToComment.txt" it should return "201" - And "user0" posts a comment with content "The second comment should not be found" on the file named "/myFileToComment.txt" it should return "201" - And "user0" posts a comment with content "My first comment to be found" on the file named "/mySharedFileToComment.txt" it should return "201" - And "user1" posts a comment with content "Other's first comment that should not be found" on the file named "/mySharedFileToComment.txt" it should return "201" - And "user1" posts a comment with content "Other's second comment to be found" on the file named "/mySharedFileToComment.txt" it should return "201" - And "user0" posts a comment with content "My first comment that should not be found" on the file named "/sharedFileToComment.txt" it should return "201" - And "user1" posts a comment with content "Other's first comment to be found" on the file named "/sharedFileToComment.txt" it should return "201" - And "user0" posts a comment with content "My second comment to be found that happens to be more verbose than the others and thus should be ellipsized" on the file named "/sharedFileToComment.txt" it should return "201" - And "user0" posts a comment with content "My third comment to be found" on the file named "/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "comment to be found" in app "files" - Then the list of search results has "6" results - And search result "0" contains - | type | comment | - | comment | My third comment to be found | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | My third comment to be found | - And search result "1" contains - | type | comment | - | comment | My second comment to be found that happens to be more … | - | authorId | user0 | - | authorName | user0 | - | path | sharedFileToComment.txt | - | fileName | sharedFileToComment.txt | - | name | My second comment to be found that happens to be more verbose than the others and thus should be ellipsized | - And search result "2" contains - | type | comment | - | comment | Other's first comment to be found | - | authorId | user1 | - | authorName | user1 | - | path | sharedFileToComment.txt | - | fileName | sharedFileToComment.txt | - | name | Other's first comment to be found | - And search result "3" contains - | type | comment | - | comment | Other's second comment to be found | - | authorId | user1 | - | authorName | user1 | - | path | mySharedFileToComment.txt | - | fileName | mySharedFileToComment.txt | - | name | Other's second comment to be found | - And search result "4" contains - | type | comment | - | comment | My first comment to be found | - | authorId | user0 | - | authorName | user0 | - | path | mySharedFileToComment.txt | - | fileName | mySharedFileToComment.txt | - | name | My first comment to be found | - And search result "5" contains - | type | comment | - | comment | My first comment to be found | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | My first comment to be found | - - Scenario: Search comment with a query that also matches a file name - Given user "user0" exists - And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt" - And "user0" posts a comment with content "A comment in myFileToComment.txt" on the file named "/myFileToComment.txt" it should return "201" - When Logging in using web as "user0" - And searching for "myFileToComment" in app "files" - Then the list of search results has "2" results - And search result "0" contains - | type | file | - | path | /myFileToComment.txt | - | name | myFileToComment.txt | - And search result "1" contains - | type | comment | - | comment | A comment in myFileToComment.txt | - | authorId | user0 | - | authorName | user0 | - | path | myFileToComment.txt | - | fileName | myFileToComment.txt | - | name | A comment in myFileToComment.txt | diff --git a/core/Controller/SearchController.php b/core/Controller/SearchController.php deleted file mode 100644 index 166e2bad53b..00000000000 --- a/core/Controller/SearchController.php +++ /dev/null @@ -1,46 +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/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index f605e076094..d5a3dcb5cd5 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -537,7 +537,6 @@ return array( 'OCP\\IPreview' => $baseDir . '/lib/public/IPreview.php', 'OCP\\IRequest' => $baseDir . '/lib/public/IRequest.php', 'OCP\\IRequestId' => $baseDir . '/lib/public/IRequestId.php', - 'OCP\\ISearch' => $baseDir . '/lib/public/ISearch.php', 'OCP\\IServerContainer' => $baseDir . '/lib/public/IServerContainer.php', 'OCP\\ISession' => $baseDir . '/lib/public/ISession.php', 'OCP\\IStreamImage' => $baseDir . '/lib/public/IStreamImage.php', @@ -1265,7 +1264,6 @@ return array( 'OC\\Core\\Controller\\RecommendedAppsController' => $baseDir . '/core/Controller/RecommendedAppsController.php', 'OC\\Core\\Controller\\ReferenceApiController' => $baseDir . '/core/Controller/ReferenceApiController.php', 'OC\\Core\\Controller\\ReferenceController' => $baseDir . '/core/Controller/ReferenceController.php', - 'OC\\Core\\Controller\\SearchController' => $baseDir . '/core/Controller/SearchController.php', 'OC\\Core\\Controller\\SetupController' => $baseDir . '/core/Controller/SetupController.php', 'OC\\Core\\Controller\\TaskProcessingApiController' => $baseDir . '/core/Controller/TaskProcessingApiController.php', 'OC\\Core\\Controller\\TeamsApiController' => $baseDir . '/core/Controller/TeamsApiController.php', @@ -1813,7 +1811,6 @@ return array( 'OC\\Route\\CachingRouter' => $baseDir . '/lib/private/Route/CachingRouter.php', 'OC\\Route\\Route' => $baseDir . '/lib/private/Route/Route.php', 'OC\\Route\\Router' => $baseDir . '/lib/private/Route/Router.php', - 'OC\\Search' => $baseDir . '/lib/private/Search.php', 'OC\\Search\\FilterCollection' => $baseDir . '/lib/private/Search/FilterCollection.php', 'OC\\Search\\FilterFactory' => $baseDir . '/lib/private/Search/FilterFactory.php', 'OC\\Search\\Filter\\BooleanFilter' => $baseDir . '/lib/private/Search/Filter/BooleanFilter.php', @@ -1824,11 +1821,6 @@ return array( 'OC\\Search\\Filter\\StringFilter' => $baseDir . '/lib/private/Search/Filter/StringFilter.php', 'OC\\Search\\Filter\\StringsFilter' => $baseDir . '/lib/private/Search/Filter/StringsFilter.php', 'OC\\Search\\Filter\\UserFilter' => $baseDir . '/lib/private/Search/Filter/UserFilter.php', - 'OC\\Search\\Provider\\File' => $baseDir . '/lib/private/Search/Provider/File.php', - 'OC\\Search\\Result\\Audio' => $baseDir . '/lib/private/Search/Result/Audio.php', - 'OC\\Search\\Result\\File' => $baseDir . '/lib/private/Search/Result/File.php', - 'OC\\Search\\Result\\Folder' => $baseDir . '/lib/private/Search/Result/Folder.php', - 'OC\\Search\\Result\\Image' => $baseDir . '/lib/private/Search/Result/Image.php', 'OC\\Search\\SearchComposer' => $baseDir . '/lib/private/Search/SearchComposer.php', 'OC\\Search\\SearchQuery' => $baseDir . '/lib/private/Search/SearchQuery.php', 'OC\\Search\\UnsupportedFilter' => $baseDir . '/lib/private/Search/UnsupportedFilter.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 3be8b2cf648..e148567b4c9 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -570,7 +570,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\IPreview' => __DIR__ . '/../../..' . '/lib/public/IPreview.php', 'OCP\\IRequest' => __DIR__ . '/../../..' . '/lib/public/IRequest.php', 'OCP\\IRequestId' => __DIR__ . '/../../..' . '/lib/public/IRequestId.php', - 'OCP\\ISearch' => __DIR__ . '/../../..' . '/lib/public/ISearch.php', 'OCP\\IServerContainer' => __DIR__ . '/../../..' . '/lib/public/IServerContainer.php', 'OCP\\ISession' => __DIR__ . '/../../..' . '/lib/public/ISession.php', 'OCP\\IStreamImage' => __DIR__ . '/../../..' . '/lib/public/IStreamImage.php', @@ -1298,7 +1297,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Controller\\RecommendedAppsController' => __DIR__ . '/../../..' . '/core/Controller/RecommendedAppsController.php', 'OC\\Core\\Controller\\ReferenceApiController' => __DIR__ . '/../../..' . '/core/Controller/ReferenceApiController.php', 'OC\\Core\\Controller\\ReferenceController' => __DIR__ . '/../../..' . '/core/Controller/ReferenceController.php', - 'OC\\Core\\Controller\\SearchController' => __DIR__ . '/../../..' . '/core/Controller/SearchController.php', 'OC\\Core\\Controller\\SetupController' => __DIR__ . '/../../..' . '/core/Controller/SetupController.php', 'OC\\Core\\Controller\\TaskProcessingApiController' => __DIR__ . '/../../..' . '/core/Controller/TaskProcessingApiController.php', 'OC\\Core\\Controller\\TeamsApiController' => __DIR__ . '/../../..' . '/core/Controller/TeamsApiController.php', @@ -1846,7 +1844,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Route\\CachingRouter' => __DIR__ . '/../../..' . '/lib/private/Route/CachingRouter.php', 'OC\\Route\\Route' => __DIR__ . '/../../..' . '/lib/private/Route/Route.php', 'OC\\Route\\Router' => __DIR__ . '/../../..' . '/lib/private/Route/Router.php', - 'OC\\Search' => __DIR__ . '/../../..' . '/lib/private/Search.php', 'OC\\Search\\FilterCollection' => __DIR__ . '/../../..' . '/lib/private/Search/FilterCollection.php', 'OC\\Search\\FilterFactory' => __DIR__ . '/../../..' . '/lib/private/Search/FilterFactory.php', 'OC\\Search\\Filter\\BooleanFilter' => __DIR__ . '/../../..' . '/lib/private/Search/Filter/BooleanFilter.php', @@ -1857,11 +1854,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Search\\Filter\\StringFilter' => __DIR__ . '/../../..' . '/lib/private/Search/Filter/StringFilter.php', 'OC\\Search\\Filter\\StringsFilter' => __DIR__ . '/../../..' . '/lib/private/Search/Filter/StringsFilter.php', 'OC\\Search\\Filter\\UserFilter' => __DIR__ . '/../../..' . '/lib/private/Search/Filter/UserFilter.php', - 'OC\\Search\\Provider\\File' => __DIR__ . '/../../..' . '/lib/private/Search/Provider/File.php', - 'OC\\Search\\Result\\Audio' => __DIR__ . '/../../..' . '/lib/private/Search/Result/Audio.php', - 'OC\\Search\\Result\\File' => __DIR__ . '/../../..' . '/lib/private/Search/Result/File.php', - 'OC\\Search\\Result\\Folder' => __DIR__ . '/../../..' . '/lib/private/Search/Result/Folder.php', - 'OC\\Search\\Result\\Image' => __DIR__ . '/../../..' . '/lib/private/Search/Result/Image.php', 'OC\\Search\\SearchComposer' => __DIR__ . '/../../..' . '/lib/private/Search/SearchComposer.php', 'OC\\Search\\SearchQuery' => __DIR__ . '/../../..' . '/lib/private/Search/SearchQuery.php', 'OC\\Search\\UnsupportedFilter' => __DIR__ . '/../../..' . '/lib/private/Search/UnsupportedFilter.php', diff --git a/lib/private/Search.php b/lib/private/Search.php deleted file mode 100644 index d51a305b331..00000000000 --- 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/Search/Provider/File.php b/lib/private/Search/Provider/File.php deleted file mode 100644 index ca4b1b8677f..00000000000 --- a/lib/private/Search/Provider/File.php +++ /dev/null @@ -1,87 +0,0 @@ -getUser(); - if (!$user) { - return []; - } - $userFolder = $rootFolder->getUserFolder($user->getUID()); - $fileQuery = new SearchQuery( - new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', '%' . $query . '%'), - (int)$limit, - (int)$offset, - [ - new SearchOrder(ISearchOrder::DIRECTION_DESCENDING, 'mtime'), - ], - $user - ); - $files = $userFolder->search($fileQuery); - $results = []; - // edit results - foreach ($files as $fileData) { - // create audio result - if ($fileData->getMimePart() === 'audio') { - $result = new \OC\Search\Result\Audio($fileData); - } - // create image result - elseif ($fileData->getMimePart() === 'image') { - $result = new \OC\Search\Result\Image($fileData); - } - // create folder result - elseif ($fileData->getMimetype() === FileInfo::MIMETYPE_FOLDER) { - $result = new \OC\Search\Result\Folder($fileData); - } - // or create file result - else { - $result = new \OC\Search\Result\File($fileData); - } - // add to results - $results[] = $result; - } - // return - return $results; - } - - public function searchPaged($query, $page, $size) { - if ($size === 0) { - return $this->search($query); - } else { - return $this->search($query, $size, ($page - 1) * $size); - } - } -} diff --git a/lib/private/Search/Result/Audio.php b/lib/private/Search/Result/Audio.php deleted file mode 100644 index 42b8ac75da0..00000000000 --- a/lib/private/Search/Result/Audio.php +++ /dev/null @@ -1,25 +0,0 @@ -getRelativePath($data->getPath()); - - $this->id = $data->getId(); - $this->name = $data->getName(); - $this->link = \OC::$server->getURLGenerator()->linkToRoute( - 'files.view.index', - [ - 'dir' => dirname($path), - 'scrollto' => $data->getName(), - ] - ); - $this->permissions = $data->getPermissions(); - $this->path = $path; - $this->size = $data->getSize(); - $this->modified = $data->getMtime(); - $this->mime_type = $data->getMimetype(); - $this->has_preview = $this->hasPreview($data); - } - - /** - * @var Folder $userFolderCache - * @deprecated 20.0.0 - */ - protected static $userFolderCache = null; - - /** - * converts a path relative to the users files folder - * eg /user/files/foo.txt -> /foo.txt - * @param string $path - * @return string relative path - * @deprecated 20.0.0 - */ - protected function getRelativePath($path) { - if (!isset(self::$userFolderCache)) { - $userSession = \OC::$server->get(IUserSession::class); - $userID = $userSession->getUser()->getUID(); - self::$userFolderCache = \OC::$server->getUserFolder($userID); - } - $relativePath = self::$userFolderCache->getRelativePath($path); - if ($relativePath === null) { - throw new \Exception("Search result not in user folder"); - } - return $relativePath; - } - - /** - * Is the preview available - * @param FileInfo $data - * @return bool - * @deprecated 20.0.0 - */ - protected function hasPreview($data) { - $previewManager = \OC::$server->get(IPreview::class); - return $previewManager->isAvailable($data); - } -} diff --git a/lib/private/Search/Result/Folder.php b/lib/private/Search/Result/Folder.php deleted file mode 100644 index 37de0a031a7..00000000000 --- a/lib/private/Search/Result/Folder.php +++ /dev/null @@ -1,21 +0,0 @@ -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) { @@ -1809,16 +1804,6 @@ class Server extends ServerContainer implements IServerContainer { 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 4279ee580c5..00000000000 --- a/lib/public/ISearch.php +++ /dev/null @@ -1,51 +0,0 @@ -