From 558877eb2b679541a3aaaa0c4f79669799b48710 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Mon, 23 Feb 2026 11:42:22 +0100 Subject: [PATCH 1/2] IcingaObjectHandler: Avoid cyclic inheritance only for hosts and commands --- .../Director/RestApi/IcingaObjectHandler.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/library/Director/RestApi/IcingaObjectHandler.php b/library/Director/RestApi/IcingaObjectHandler.php index 95fa3cfd..369fb49b 100644 --- a/library/Director/RestApi/IcingaObjectHandler.php +++ b/library/Director/RestApi/IcingaObjectHandler.php @@ -140,18 +140,21 @@ class IcingaObjectHandler extends RequestHandler $object->replaceWith(IcingaObject::createByType($type, $data, $db)); } - if (in_array((int) $object->get('id'), $object->listAncestorIds())) { - throw new RuntimeException( - 'Import loop detected for the object ' - . $object->getObjectName() . ' -> Imports: ' - . implode(', ', $object->getImports()) - ); - } + // Avoid cyclic imports for hosts and commands + if (in_array($object->getShortTableName(), ['host', 'command'], true)) { + if (in_array((int) $object->get('id'), $object->listAncestorIds())) { + throw new RuntimeException( + 'Import loop detected for the object ' + . $object->getObjectName() . ' -> Imports: ' + . implode(', ', $object->getImports()) + ); + } - if (isset($data['imports']) && in_array($object->get('object_name'), $data['imports'])) { - throw new RuntimeException( - 'You can not import the same object into itself: ' . $object->getObjectName() - ); + if (isset($data['imports']) && in_array($object->get('object_name'), $data['imports'])) { + throw new RuntimeException( + 'You can not import the same object into itself: ' . $object->getObjectName() + ); + } } $this->persistChanges($object); From bed69a7a1892c7b6379a96eb843ba614b3f5285d Mon Sep 17 00:00:00 2001 From: raviks789 Date: Mon, 23 Feb 2026 11:54:23 +0100 Subject: [PATCH 2/2] DirectorObjectForm: Avoid cyclic inheritance only for hosts and commands --- library/Director/Web/Form/DirectorObjectForm.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index 80a538d7..6d5bfb33 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -1289,7 +1289,13 @@ abstract class DirectorObjectForm extends DirectorForm 'class' => 'autosubmit', 'validators' => [ new Zend_Validate_Callback(function ($value) { - $templateTree = new TemplateTree($this->object->getShortTableName(), $this->getDb()); + $objectInstance = $this->object->getShortTableName(); + // Avoid cyclic imports for hosts and commands + if ($objectInstance !== 'host' && $objectInstance !== 'command') { + return true; + } + + $templateTree = new TemplateTree($objectInstance, $this->getDb()); $importsElement = $this->getElement('imports'); $objectName = $this->object->getObjectName(); if (in_array($objectName, $value, true)) {