Monitoring\Controller#getRestriction(): return filters matching all, not none

Filter::matchAny() without any subfilters matches none,
Filter::matchAll() without any subfilters matches all.
This commit is contained in:
Alexander A. Klimov 2019-04-15 16:03:43 +02:00
parent 08c879249b
commit d40e85b8a3
1 changed files with 7 additions and 2 deletions

View File

@ -97,7 +97,7 @@ class Controller extends IcingaWebController
* *
* @param string $name Name of the restriction * @param string $name Name of the restriction
* *
* @return Filter|null Filter object or null if the authenticated user is not restricted * @return Filter Filter object
* @throws ConfigurationError If the restriction contains invalid filter columns * @throws ConfigurationError If the restriction contains invalid filter columns
*/ */
protected function getRestriction($name) protected function getRestriction($name)
@ -115,7 +115,7 @@ class Controller extends IcingaWebController
)); ));
foreach ($this->getRestrictions($name) as $filter) { foreach ($this->getRestrictions($name) as $filter) {
if ($filter === '*') { if ($filter === '*') {
return Filter::matchAny(); return Filter::matchAll();
} }
try { try {
$restriction->addFilter(Filter::fromQueryString($filter)); $restriction->addFilter(Filter::fromQueryString($filter));
@ -138,6 +138,11 @@ class Controller extends IcingaWebController
); );
} }
} }
if ($restriction->isEmpty()) {
return Filter::matchAll();
}
return $restriction; return $restriction;
} }
} }