From 8b903486d35246679122ccd6c92392b2a4359f66 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 11 Mar 2016 13:56:34 +0100 Subject: [PATCH] IcingaObject: support merge for objects with no CV --- library/Director/Objects/IcingaObject.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index ed3456eb..b37155f3 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -1301,12 +1301,19 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer public function merge(IcingaObject $object) { $object = clone($object); - $vars = $object->getVars(); - $object->vars = array(); + + if ($object->supportsCustomVars()) { + $vars = $object->getVars(); + $object->vars = array(); + } + $this->setProperties((array) $object->toPlainObject(null, true)); - $myVars = $this->vars(); - foreach ($vars as $key => $var) { - $myVars->set($key, $var); + + if ($object->supportsCustomVars()) { + $myVars = $this->vars(); + foreach ($vars as $key => $var) { + $myVars->set($key, $var); + } } return $this;