Skip to content

Commit 6c948b0

Browse files
Merge pull request #4400 from nextcloud/backport/4396/stable31
2 parents cc509ed + 2df2e32 commit 6c948b0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/ACL/ACLManager.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ private function getRelevantPaths(string $path): array {
137137
public function getRelevantRulesForPath(array $paths, bool $cache = true): array {
138138
$allPaths = [];
139139
foreach ($paths as $path) {
140-
$allPaths = array_unique(array_merge($allPaths, $this->getRelevantPaths($path)));
140+
foreach ($this->getRelevantPaths($path) as $relevantPath) {
141+
$allPaths[$relevantPath] = true;
142+
}
141143
}
142144

143-
return $this->getRules($allPaths, $cache);
145+
return $this->getRules(array_keys($allPaths), $cache);
144146
}
145147

146148
public function getACLPermissionsForPath(string $path): int {
@@ -169,10 +171,14 @@ public function testACLPermissionsForPath(string $path, array $newRules): int {
169171
*/
170172
public function getPermissionsForPathFromRules(string $path, array $rules): int {
171173
$path = ltrim($path, '/');
172-
$relevantPaths = $this->getRelevantPaths($path);
173-
$rules = array_intersect_key($rules, array_flip($relevantPaths));
174+
$filteredRules = [];
175+
foreach ($this->getRelevantPaths($path) as $relevantPath) {
176+
if (isset($rules[$relevantPath])) {
177+
$filteredRules[$relevantPath] = $rules[$relevantPath];
178+
}
179+
}
174180

175-
return $this->calculatePermissionsForPath($rules);
181+
return $this->calculatePermissionsForPath($filteredRules);
176182
}
177183

178184
/**

0 commit comments

Comments
 (0)