From d5807495a03e0418ecc2bcdd73a8b902466732ae Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 22 May 2018 14:40:56 +0200 Subject: [PATCH] TemplateTree: load inheritance for unstored... ...objects even if the given parent is not a template. This happens with fake objects while managing overrides --- library/Director/Resolver/TemplateTree.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/Director/Resolver/TemplateTree.php b/library/Director/Resolver/TemplateTree.php index 2413bdbd..5352b915 100644 --- a/library/Director/Resolver/TemplateTree.php +++ b/library/Director/Resolver/TemplateTree.php @@ -145,13 +145,18 @@ class TemplateTree protected function getAncestorsForUnstoredObject(IcingaObject $object) { $this->requireTree(); - $names = $object->imports()->listImportNames(); $ancestors = []; - foreach ($names as $name) { - if (! array_key_exists($name, $this->templateNameToId)) { - continue; + foreach ($object->imports() as $import) { + $name = $import->getObjectName(); + 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); // Hint: inheritance order matters