diff --git a/lib/ACL/ACLCacheWrapper.php b/lib/ACL/ACLCacheWrapper.php index 4c855ed57..623b4d2e5 100644 --- a/lib/ACL/ACLCacheWrapper.php +++ b/lib/ACL/ACLCacheWrapper.php @@ -108,6 +108,9 @@ private function preloadEntries(array $entries): array { */ private function getSearchFilter(): ISearchOperator { $forbiddenPaths = $this->aclManager->getForbiddenPaths($this->getNumericStorageId(), ''); + if (count($forbiddenPaths) === 0) { + return new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, []); + } $filters = array_map(fn (string $path) => new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_NOT, [ new SearchComparison(ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE, 'path', SearchComparison::escapeLikeParameter($path) . '/%') diff --git a/tests/ACL/ACLCacheWrapperTest.php b/tests/ACL/ACLCacheWrapperTest.php index 5484ef5de..fee8a68a0 100644 --- a/tests/ACL/ACLCacheWrapperTest.php +++ b/tests/ACL/ACLCacheWrapperTest.php @@ -128,7 +128,6 @@ public function testSearchNonRead(): void { $sourceStorage->touch('bar/test2.txt', 201); $sourceStorage->touch('bar/test3.txt', 202); $sourceStorage->getScanner()->scan(''); - $this->aclPermissions['bar'] = 0; $cache = new ACLCacheWrapper($sourceStorage->getCache(), $this->aclManager, 0, false); @@ -141,6 +140,16 @@ public function testSearchNonRead(): void { $result = $cache->searchQuery($query); $paths = array_map(fn (ICacheEntry $entry) => $entry->getPath(), $result); + $this->assertEquals([ + 'bar/test3.txt', + 'bar/test2.txt' + ], $paths); + + $this->aclPermissions['bar'] = 0; + + $result = $cache->searchQuery($query); + $paths = array_map(fn (ICacheEntry $entry) => $entry->getPath(), $result); + $this->assertEquals([ 'foo/test3.txt', 'foo/test2.txt'