IcingaObject: getRenderingZone() must succeed...

...even when no config is given

refs #1394
This commit is contained in:
Thomas Gelf 2018-02-20 15:56:17 +01:00
parent 56f44b9ff1
commit 41e379b008
1 changed files with 19 additions and 4 deletions

View File

@ -1586,15 +1586,30 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
if ($this->hasProperty('zone_id')) {
if (! $this->supportsImports()) {
if ($zoneId = $this->get('zone_id')) {
// Config has a lookup cache, is faster:
return $config->getZoneName($zoneId);
// TODO: this is ugly.
if ($config === null) {
return IcingaZone::loadWithAutoIncId(
$zoneId,
$this->getConnection()
)->getObjectName();
} else {
// Config has a lookup cache, is faster:
return $config->getZoneName($zoneId);
}
}
}
try {
if ($zoneId = $this->getSingleResolvedProperty('zone_id')) {
// Config has a lookup cache, is faster:
return $config->getZoneName($zoneId);
if ($config === null) {
return IcingaZone::loadWithAutoIncId(
$zoneId,
$this->getConnection()
)->getObjectName();
} else {
// Config has a lookup cache, is faster:
return $config->getZoneName($zoneId);
}
}
} catch (Exception $e) {
return self::RESOLVE_ERROR;