[icinga-checkins] icinga.org: icingaweb2-module-director/feature/nested-apply-rules-12033: IcingaTemplateResolver: fix resolver for unstored...

git at icinga.org git at icinga.org
Fri Oct 21 10:08:07 CEST 2016


Module: icingaweb2-module-director
Branch: feature/nested-apply-rules-12033
Commit: 76936c7efb83e7e2a402f246882c0f38795f2dbe
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=76936c7efb83e7e2a402f246882c0f38795f2dbe

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct 20 01:32:52 2016 +0000

IcingaTemplateResolver: fix resolver for unstored...

...objects

refs #12938

---

 .../Director/Objects/IcingaTemplateResolver.php    |   26 ++++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/library/Director/Objects/IcingaTemplateResolver.php b/library/Director/Objects/IcingaTemplateResolver.php
index a002a01..7b70abc 100644
--- a/library/Director/Objects/IcingaTemplateResolver.php
+++ b/library/Director/Objects/IcingaTemplateResolver.php
@@ -144,7 +144,16 @@ class IcingaTemplateResolver
 
     public function fetchResolvedParents()
     {
-        return $this->fetchObjectsById($this->listResolvedParentIds());
+        if ($this->object->hasBeenLoadedFromDb()) {
+            return $this->fetchObjectsById($this->listResolvedParentIds());
+        }
+
+        $objects = array();
+        foreach ($this->object->imports()->getObjects() as $parent) {
+            $objects += $parent->templateResolver()->fetchResolvedParents();
+        }
+
+        return $objects;
     }
 
     public function listResolvedParentIds()
@@ -214,10 +223,17 @@ class IcingaTemplateResolver
         if (array_key_exists($id, $list)) {
             $list = array_keys($list);
             $list[] = $id;
-            throw new NestingError(
-                'Loop detected: %s',
-                implode(' -> ', $this->getNamesForIds($list))
-            );
+            if (is_numeric($id)) {
+                throw new NestingError(
+                    'Loop detected: %s',
+                    implode(' -> ', $this->getNamesForIds($list))
+                );
+            } else {
+                throw new NestingError(
+                    'Loop detected: %s',
+                    implode(' -> ', $list)
+                );
+            }
         }
     }
 



More information about the icinga-checkins mailing list