IcingaObject: log former related set state

This commit is contained in:
Thomas Gelf 2016-02-29 22:54:46 +01:00
parent c9a7c9d085
commit 29b1253bea
2 changed files with 41 additions and 0 deletions

View File

@ -113,6 +113,35 @@ class ExtensibleSet
return $plain; return $plain;
} }
public function getPlainUnmodifiedObject()
{
if ($this->fromDb === null) {
return null;
}
$old = $this->fromDb;
if ($old['override'] !== null) {
if (empty($old['blacklist']) && empty($old['extend'])) {
return $old['override'];
}
}
$plain = (object) array();
if ($old['override'] !== null) {
$plain->override = $old['override'];
}
if (! empty($old['extend'])) {
$plain->extend = $old['extend'];
}
if (! empty($old['blacklist'])) {
$plain->blacklist = $old['blacklist'];
}
return $plain;
}
public function hasBeenLoadedFromDb() public function hasBeenLoadedFromDb()
{ {
return $this->fromDb !== null; return $this->fromDb !== null;

View File

@ -1290,6 +1290,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
foreach ($this->relatedSets() as $property => $set) { foreach ($this->relatedSets() as $property => $set) {
if ($resolved) { if ($resolved) {
if ($this->supportsImports()) {
$set = clone($set);
foreach ($this->importedObjects() as $parent) {
$set->inheritFrom($parent->getRelatedSet($property));
}
}
$values = $set->getResolvedValues(); $values = $set->getResolvedValues();
if (empty($values)) { if (empty($values)) {
if (!$skipDefaults) { if (!$skipDefaults) {
@ -1377,6 +1384,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
} }
} }
foreach ($this->relatedSets() as $property => $set) {
if ($set->isEmpty()) { continue; }
$props[$property] = $set->getPlainUnmodifiedObject();
}
return $props; return $props;
} }