CustomVariables: do not replace vars on modification

This commit is contained in:
Thomas Gelf 2015-06-24 09:42:50 +02:00
parent 7aba7fdb5f
commit a2790652ec
1 changed files with 8 additions and 4 deletions

View File

@ -71,11 +71,16 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
$value = CustomVariable::create($key, $value); $value = CustomVariable::create($key, $value);
} }
if (isset($this->$key) && $value->equals($this->get($key))) { if (isset($this->$key)) {
if ($value->equals($this->get($key))) {
return $this; return $this;
} else {
$this->vars[$key]->setValue($value->getValue());
}
} else {
$this->vars[$key] = $value;
} }
$this->vars[$key] = $value;
$this->modified = true; $this->modified = true;
$this->refreshIndex(); $this->refreshIndex();
@ -105,7 +110,6 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
$vars->vars[$row->varname] = CustomVariable::fromDbRow($row); $vars->vars[$row->varname] = CustomVariable::fromDbRow($row);
} }
$vars->refreshIndex(); $vars->refreshIndex();
return $vars; return $vars;
} }