From 47bfb2d31d91c1713ded875e445fea44317366c0 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 18 Apr 2017 11:44:06 +0200 Subject: [PATCH] IcingaObjectImports: add meaningful error... ...would have saved me some troubleshooting time --- library/Director/Objects/IcingaObjectImports.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/Director/Objects/IcingaObjectImports.php b/library/Director/Objects/IcingaObjectImports.php index 470578af..4e8ffa6c 100644 --- a/library/Director/Objects/IcingaObjectImports.php +++ b/library/Director/Objects/IcingaObjectImports.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Objects; use Countable; use Exception; +use Icinga\Exception\ProgrammingError; use Iterator; use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c; use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer; @@ -289,7 +290,15 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer return true; } - $objectId = (int) $this->object->get('id'); + $objectId = $this->object->get('id'); + if ($objectId === null) { + throw new ProgrammingError( + 'Cannot store imports for unstored object with no ID' + ); + } else { + $objectId = (int) $objectId; + } + $type = $this->getType(); $objectCol = $type . '_id';