CustomVariable: improve modification handling
This commit is contained in:
parent
b9a4820515
commit
053854e2c6
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue