Skip to content

Commit

Permalink
Merge pull request #1643 from Icinga/feature/group-apply-should-ignor…
Browse files Browse the repository at this point in the history
…e-templates

GroupMembershipResolver: ignore templates...
  • Loading branch information
lazyfrosch committed Sep 18, 2018
2 parents 8526a55 + 16bf0ce commit e895978
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions library/Director/Objects/GroupMembershipResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function refreshDb($force = false)

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');
Expand Down Expand Up @@ -150,9 +155,11 @@ public function addObject(IcingaObject $object)
$this->objects = [];
}

$this->objects[$id] = $object;

$this->includeChildObjects($object);
if ($object->isTemplate()) {
$this->includeChildObjects($object);
} else {
$this->objects[$id] = $object;
}

return $this;
}
Expand All @@ -172,12 +179,9 @@ public function addObjects(array $objects)

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,
Expand Down Expand Up @@ -467,6 +471,9 @@ protected function recheckAllObjects($groups)
if ($object->shouldBeRemoved()) {
continue;
}
if ($object->isTemplate()) {
continue;
}

$mt = microtime(true);
$id = $object->get('id');
Expand Down

0 comments on commit e895978

Please sign in to comment.