diff --git a/library/Director/CustomVariable/CustomVariable.php b/library/Director/CustomVariable/CustomVariable.php index 8f7df292..579b49f1 100644 --- a/library/Director/CustomVariable/CustomVariable.php +++ b/library/Director/CustomVariable/CustomVariable.php @@ -100,6 +100,12 @@ abstract class CustomVariable implements IcingaConfigRenderer return $this->setModified(false); } + public function setLoadedFromDb($loaded = true) + { + $this->loadedFromDb = $loaded; + return $this; + } + abstract public function equals(CustomVariable $var); public function differsFrom(CustomVariable $var) @@ -166,6 +172,7 @@ abstract class CustomVariable implements IcingaConfigRenderer } $var->loadedFromDb = true; + $var->modified = false; return $var; } diff --git a/library/Director/CustomVariable/CustomVariableArray.php b/library/Director/CustomVariable/CustomVariableArray.php index bca7274d..28f2c8c3 100644 --- a/library/Director/CustomVariable/CustomVariableArray.php +++ b/library/Director/CustomVariable/CustomVariableArray.php @@ -43,13 +43,22 @@ class CustomVariableArray extends CustomVariable $new[] = self::wantCustomVariable($k, $v); } - // WTF? - if ($this->value === $new) { - return $this; + $equals = true; + if (is_array($this->value) && count($new) === count($this->value)) { + foreach ($this->value as $k => $v) { + if (! $new[$k]->equals($v)) { + $equals = false; + break; + } + } + } else { + $equals = false; } - $this->value = $new; - $this->setModified(); + if (! $equals) { + $this->value = $new; + $this->setModified(); + } return $this; }