diff --git a/lib/ACL/ACLCacheWrapper.php b/lib/ACL/ACLCacheWrapper.php index 300fcfdfc..a3a5c60e9 100644 --- a/lib/ACL/ACLCacheWrapper.php +++ b/lib/ACL/ACLCacheWrapper.php @@ -117,6 +117,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 7154d9231..ea39d4243 100644 --- a/tests/ACL/ACLCacheWrapperTest.php +++ b/tests/ACL/ACLCacheWrapperTest.php @@ -129,7 +129,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); @@ -142,6 +141,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'