CustomVariables: improve modification handling

This commit is contained in:
Thomas Gelf 2015-08-28 23:42:40 +02:00
parent eabd848d5f
commit 1936ad8997
1 changed files with 6 additions and 1 deletions

View File

@ -75,7 +75,11 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
if ($value->equals($this->get($key))) {
return $this;
} else {
$this->vars[$key]->setValue($value->getValue());
if (get_class($this->vars[$key]) === get_class($value)) {
$this->vars[$key]->setValue($value->getValue());
} else {
$this->vars[$key] = $value->setLoadedFromDb()->setModified();
}
}
} else {
$this->vars[$key] = $value;
@ -115,6 +119,7 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
$vars->vars[$row->varname] = CustomVariable::fromDbRow($row);
}
$vars->refreshIndex();
$vars->setUnmodified();
return $vars;
}