From da651ce6bc55750e96426cf1309889844d8dc73a Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 6 Jul 2023 22:33:20 +0200 Subject: [PATCH] refactor: adjust to unexposed searchBySystemTag - in this backport we have to drop the breaking addition in \OCP\Files\Folder - this requires adjustments in check for the existance of the method but also in testing - another change in \OCP\SystemTag\ISystemTagManager can be applied as this interface is not implemented elsewhere Signed-off-by: Arthur Schiwon --- apps/dav/lib/Connector/Sabre/FilesReportPlugin.php | 2 +- apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php | 2 ++ lib/public/SystemTag/ISystemTagManager.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php index 4b26d83777925..1c6727e68ca44 100644 --- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php @@ -336,7 +336,7 @@ protected function processFilterRulesForFileNodes(array $filterRules, ?int $limi // type check to ensure searchBySystemTag is available, it is not // exposed in API yet - if (!empty($systemTagIds)) { + if (!empty($systemTagIds) && method_exists($this->userFolder, 'searchBySystemTag')) { $tags = $this->tagManager->getTagsByIds($systemTagIds, $this->userSession->getUser()); // For we run DB queries per tag and require intersection, we cannot apply limit and offset for DB queries on multi tag search. diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index f1f1cc8b27f5e..2bbe7bef6defc 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -114,6 +114,8 @@ protected function setUp(): void { $this->userFolder = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() + ->addMethods(['searchBySystemTag']) + ->onlyMethods(get_class_methods(Folder::class)) ->getMock(); $this->previewManager = $this->getMockBuilder(IPreview::class) diff --git a/lib/public/SystemTag/ISystemTagManager.php b/lib/public/SystemTag/ISystemTagManager.php index 0f5c373c49f66..93eda57f0c46e 100644 --- a/lib/public/SystemTag/ISystemTagManager.php +++ b/lib/public/SystemTag/ISystemTagManager.php @@ -46,7 +46,7 @@ interface ISystemTagManager { * @throws TagNotFoundException if at least one given tag ids did no exist * The message contains a json_encoded array of the ids that could not be found * - * @since 9.0.0, optional parameter $user added in 28.0.0 + * @since 9.0.0, optional parameter $user added in 27.0.1 */ public function getTagsByIds($tagIds, ?IUser $user = null): array;