From 9b373e9d109910adb4ea03844be731bd49413d22 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 6 Aug 2015 17:21:52 +0200 Subject: [PATCH] Fix issue that caused IniWriter to fail on empty configs --- library/Icinga/File/Ini/Dom/Document.php | 1 + library/Icinga/File/Ini/Dom/Section.php | 2 +- library/Icinga/File/Ini/IniWriter.php | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Icinga/File/Ini/Dom/Document.php b/library/Icinga/File/Ini/Dom/Document.php index eca296f2a..e9f2a5a4f 100644 --- a/library/Icinga/File/Ini/Dom/Document.php +++ b/library/Icinga/File/Ini/Dom/Document.php @@ -67,6 +67,7 @@ class Document */ public function render() { + $sections = array(); foreach ($this->sections as $section) { $sections []= $section->render(); } diff --git a/library/Icinga/File/Ini/Dom/Section.php b/library/Icinga/File/Ini/Dom/Section.php index 0ae9b689c..960003394 100644 --- a/library/Icinga/File/Ini/Dom/Section.php +++ b/library/Icinga/File/Ini/Dom/Section.php @@ -7,7 +7,7 @@ class Section { /** * @var string - * + */ protected $name; /** diff --git a/library/Icinga/File/Ini/IniWriter.php b/library/Icinga/File/Ini/IniWriter.php index f6ad56680..ab024bf62 100644 --- a/library/Icinga/File/Ini/IniWriter.php +++ b/library/Icinga/File/Ini/IniWriter.php @@ -178,8 +178,9 @@ class IniWriter Logger::warning('Section-less property ' . (string)$directives . ' was ignored.'); continue; } - $newSection = $newconfig->getSection($section); - if (isset($newSection)) { + + if ($newconfig->hasSection($section)) { + $newSection = $newconfig->getSection($section); $oldDomSection = $doc->getSection($section); foreach ($directives as $key => $value) { if ($value instanceof ConfigObject) {