From f3e526f95fdf397f9cbaaea9f832ca1adad7b05a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 5 Mar 2016 12:56:29 +0100 Subject: [PATCH] IcingaObjectImports: gracefully ignore empty members --- library/Director/Objects/IcingaObjectImports.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/Director/Objects/IcingaObjectImports.php b/library/Director/Objects/IcingaObjectImports.php index f84e2580..919309d7 100644 --- a/library/Director/Objects/IcingaObjectImports.php +++ b/library/Director/Objects/IcingaObjectImports.php @@ -147,9 +147,16 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer public function add($import) { + $class = $this->getImportClass(); + // TODO: only one query when adding array if (is_array($import)) { foreach ($import as $i) { + // Gracefully ignore null members or empty strings + if (! $i instanceof $class && strlen($i) === 0) { + continue; + } + $this->add($i); } return $this; @@ -159,7 +166,6 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer return $this; } - $class = $this->getImportClass(); $connection = $this->object->getConnection(); if ($import instanceof $class) {