TemplateTree: load inheritance for unstored...

...objects even if the given parent is not a template. This happens with fake
objects while managing overrides
This commit is contained in:
Thomas Gelf 2018-05-22 14:40:56 +02:00
parent d8b1207254
commit d5807495a0

View File

@ -145,13 +145,18 @@ class TemplateTree
protected function getAncestorsForUnstoredObject(IcingaObject $object) protected function getAncestorsForUnstoredObject(IcingaObject $object)
{ {
$this->requireTree(); $this->requireTree();
$names = $object->imports()->listImportNames();
$ancestors = []; $ancestors = [];
foreach ($names as $name) { foreach ($object->imports() as $import) {
if (! array_key_exists($name, $this->templateNameToId)) { $name = $import->getObjectName();
continue; if ($import->hasBeenLoadedFromDb()) {
$pid = $import->get('id');
} else {
if (! array_key_exists($name, $this->templateNameToId)) {
continue;
}
$pid = $this->templateNameToId[$name];
} }
$pid = $this->templateNameToId[$name];
$this->getAncestorsById($pid, $ancestors); $this->getAncestorsById($pid, $ancestors);
// Hint: inheritance order matters // Hint: inheritance order matters