[icinga-checkins] icinga.org: icingaweb2-module-director/feature/test-runner-12905: ServiceController|IcingaServiceForm: Catching NestingError for the form to load

git at icinga.org git at icinga.org
Thu Oct 13 14:03:11 CEST 2016


Module: icingaweb2-module-director
Branch: feature/test-runner-12905
Commit: 1a2cede13f42a84ef0b0776ec2c7ea2db1729b86
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=1a2cede13f42a84ef0b0776ec2c7ea2db1729b86

Author: Markus Frosch <lazyfrosch at icinga.org>
Date:   Thu Oct 13 12:25:11 2016 +0200

ServiceController|IcingaServiceForm: Catching NestingError for the form to load

fixes #11803

---

 application/controllers/ServiceController.php |   26 ++++++++++++++-----------
 application/forms/IcingaServiceForm.php       |    9 +++++++--
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php
index 6af7918..738cf73 100644
--- a/application/controllers/ServiceController.php
+++ b/application/controllers/ServiceController.php
@@ -2,6 +2,7 @@
 
 namespace Icinga\Module\Director\Controllers;
 
+use Icinga\Module\Director\Exception\NestingError;
 use Icinga\Module\Director\Web\Controller\ObjectController;
 use Icinga\Module\Director\Objects\IcingaService;
 use Icinga\Module\Director\Objects\IcingaHost;
@@ -102,17 +103,20 @@ class ServiceController extends ObjectController
             );
         }
 
-        if ($object->isTemplate()
-            && $object->getResolvedProperty('check_command_id')
-        ) {
-
-            $this->view->actionLinks .= ' ' . $this->view->qlink(
-                'Create apply-rule',
-                'director/service/add',
-                array('apply' => $object->object_name),
-                array('class'    => 'icon-plus')
-            );
-
+        try {
+            if ($object->isTemplate()
+                && $object->getResolvedProperty('check_command_id')
+            ) {
+
+                $this->view->actionLinks .= ' ' . $this->view->qlink(
+                    'Create apply-rule',
+                    'director/service/add',
+                    array('apply' => $object->object_name),
+                    array('class'    => 'icon-plus')
+                );
+            }
+        } catch (NestingError $nestingError) {
+            // ignore the error for the form
         }
     }
 
diff --git a/application/forms/IcingaServiceForm.php b/application/forms/IcingaServiceForm.php
index 0334d57..2ba934d 100644
--- a/application/forms/IcingaServiceForm.php
+++ b/application/forms/IcingaServiceForm.php
@@ -2,6 +2,7 @@
 
 namespace Icinga\Module\Director\Forms;
 
+use Icinga\Module\Director\Exception\NestingError;
 use Icinga\Module\Director\Web\Form\DirectorObjectForm;
 use Icinga\Module\Director\Objects\IcingaHost;
 use Icinga\Module\Director\Objects\IcingaService;
@@ -42,8 +43,12 @@ class IcingaServiceForm extends DirectorObjectForm
             return $this->setupInherited();
         }
 
-        if (!$this->isNew() && $this->host === null) {
-            $this->host = $this->object->getResolvedRelated('host');
+        try {
+            if (!$this->isNew() && $this->host === null) {
+                $this->host = $this->object->getResolvedRelated('host');
+            }
+        } catch(NestingError $nestingError) {
+            // ignore for the form to load
         }
 
         if ($this->host === null) {



More information about the icinga-checkins mailing list