diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index d68a0305..e366d179 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -749,6 +749,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer return $this->imports; } + public function gotImports() + { + return $this->imports !== null; + } + public function setImports($imports) { if (! is_array($imports) && $imports !== null) { diff --git a/library/Director/Objects/IcingaTemplateResolver.php b/library/Director/Objects/IcingaTemplateResolver.php index a075baf1..1890e0d7 100644 --- a/library/Director/Objects/IcingaTemplateResolver.php +++ b/library/Director/Objects/IcingaTemplateResolver.php @@ -79,8 +79,16 @@ class IcingaTemplateResolver $this->requireTemplates(); if ($id === null) { - $id = $this->object->id; - if (! $id && $this->object->imports()->hasBeenModified()) { + $object = $this->object; + + if ($object->hasBeenLoadedFromDb()) { + + if ($object->gotImports() && $object->imports()->hasBeenModified()) { + return $this->listUnstoredParentIds(); + } + + $id = $object->id; + } else { return $this->listUnstoredParentIds(); } } @@ -210,7 +218,7 @@ class IcingaTemplateResolver protected function getIdsForNames($names) { - $id = array(); + $ids = array(); foreach ($names as $name) { $ids[] = $this->getIdForName($name); }