GroupMembershipResolver: ignore templates...

...but continue checking their children

refs #1618
This commit is contained in:
Thomas Gelf 2018-09-17 15:12:26 +02:00
parent 8526a55e47
commit 16bf0ce5c3

View File

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