From f2d9e1a544cc43524a4b561df37d2a445cd1bea9 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 7 Mar 2016 18:10:09 +0100 Subject: [PATCH] IcingaObject: fix key handling for unresolved props --- library/Director/Objects/IcingaObject.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 4cd4619e..24fbf8ab 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -186,13 +186,14 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer protected function resolveUnresolvedRelatedProperty($name) { - $class = $this->getRelationClass($name); + $short = substr($name, 0, -3); + $class = $this->getRelationClass($short); $object = $class::load( $this->unresolvedRelatedProperties[$name], $this->connection ); - $this->$key = $object->id; + $this->$name = $object->id; unset($this->unresolvedRelatedProperties[$name]); } @@ -235,8 +236,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer if (substr($key, -3) === '_id') { $short = substr($key, 0, -3); if ($this->hasRelation($short)) { - if (array_key_exists($short, $this->unresolvedRelatedProperties)) { - $this->resolveUnresolvedRelatedProperty($short); + if (array_key_exists($key, $this->unresolvedRelatedProperties)) { + $this->resolveUnresolvedRelatedProperty($key); } } }