mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-06-09 00:33:03 -04:00
Fix/avoid cyclic inheritance only for host and command (#3037)
fixes #3036
This commit is contained in:
commit
fed11fc0e4
2 changed files with 21 additions and 12 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue