mirror of
https://github.com/netzbegruenung/groupfolders.git
synced 2024-05-04 10:23:41 +02:00
Fix argument null fatal in case of empty array
This commit is contained in:
parent
045577176e
commit
5165180e0a
|
@ -81,7 +81,7 @@ class RuleManager {
|
|||
$result[$row['fileid']][] = $rule;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
return $this->filterRules($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +163,7 @@ class RuleManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
return $this->filterRules($result);
|
||||
}
|
||||
|
||||
private function getId(int $storageId, string $path): int {
|
||||
|
@ -197,6 +197,18 @@ class RuleManager {
|
|||
return $this->rulesByPath($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures paths with no rules are not returned.
|
||||
*
|
||||
* @param (Rule[])[] $rules
|
||||
* @return (Rule[])[]
|
||||
*/
|
||||
private function filterRules(array $rules): array {
|
||||
return array_filter($rules, function($path) {
|
||||
return !empty($path);
|
||||
});
|
||||
}
|
||||
|
||||
private function rulesByPath(array $rows, array $result = []): array {
|
||||
foreach ($rows as $row) {
|
||||
if (!isset($result[$row['path']])) {
|
||||
|
@ -207,7 +219,8 @@ class RuleManager {
|
|||
$result[$row['path']][] = $rule;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
||||
return $this->filterRules($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue