Merge pull request #1643 from Icinga/feature/group-apply-should-ignore-templates

GroupMembershipResolver: ignore templates...
This commit is contained in:
Markus Frosch 2018-09-18 09:50:18 +02:00 committed by GitHub
commit e895978ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 8 deletions

View File

@ -82,6 +82,11 @@ abstract class GroupMembershipResolver
Benchmark::measure('Rechecking all objects');
$this->recheckAllObjects($this->getAppliedGroups());
if (empty($this->objects)) {
Benchmark::measure('Nothing to check, got no qualified object');
return $this;
}
Benchmark::measure('Recheck done, loading existing mappings');
$this->fetchStoredMappings();
Benchmark::measure('Ready, going to store new mappings');
@ -150,9 +155,11 @@ abstract class GroupMembershipResolver
$this->objects = [];
}
$this->objects[$id] = $object;
$this->includeChildObjects($object);
if ($object->isTemplate()) {
$this->includeChildObjects($object);
} else {
$this->objects[$id] = $object;
}
return $this;
}
@ -172,12 +179,9 @@ abstract class GroupMembershipResolver
protected function includeChildObjects(IcingaObject $object)
{
if ($object->get('object_type') !== 'template') {
return $this;
}
$query = $this->db->select()
->from(['o' => $object->getTableName()]);
->from(['o' => $object->getTableName()])
->where('o.object_type = ?', 'object');
IcingaObjectFilterHelper::filterByTemplate(
$query,
@ -467,6 +471,9 @@ abstract class GroupMembershipResolver
if ($object->shouldBeRemoved()) {
continue;
}
if ($object->isTemplate()) {
continue;
}
$mt = microtime(true);
$id = $object->get('id');