Fix host templates not usable with hostgroup restrictions

Before, for new hosts the code checked whether the host is part of any
restricted hostgroup only if the host's groups got modified directly.
I honestly don't know how that should be possible, since one can't add
host groups directly if restricted.
Now, for new hosts the code checks whether the resolved host groups
match at least one of the restricted host groups.
This commit is contained in:
Eric Lippmann 2020-03-20 09:09:00 +01:00
parent bf0653d238
commit db97470a48

View File

@ -57,13 +57,11 @@ class HostgroupRestriction extends ObjectRestriction
} }
if (! $host->hasBeenLoadedFromDb()) { if (! $host->hasBeenLoadedFromDb()) {
if ($host->hasModifiedGroups()) {
foreach ($this->listRestrictedHostgroups() as $group) { foreach ($this->listRestrictedHostgroups() as $group) {
if ($host->hasGroup($group)) { if ($host->hasGroup($group)) {
return true; return true;
} }
} }
}
return false; return false;
} }