[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaTemplateResolver: more tweaking

git at icinga.org git at icinga.org
Fri Oct 14 11:40:25 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 98acba9fb41f434c6e6e0f52ced9deb82632f1d6
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=98acba9fb41f434c6e6e0f52ced9deb82632f1d6

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri Oct 14 09:40:01 2016 +0000

IcingaTemplateResolver: more tweaking

refs #12922

---

 library/Director/Objects/IcingaObject.php           |    5 +++++
 library/Director/Objects/IcingaTemplateResolver.php |   14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index d68a030..e366d17 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 a075baf..1890e0d 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);
         }



More information about the icinga-checkins mailing list