[icinga-checkins] icinga.org: icingaweb2-module-director/master: ConfigDiff: more context, fix diff with empty

git at icinga.org git at icinga.org
Mon Aug 1 09:00:17 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 7655ad451ac8bc8a03bf84db643463de5d2f592c
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=7655ad451ac8bc8a03bf84db643463de5d2f592c

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Aug  1 06:49:39 2016 +0000

ConfigDiff: more context, fix diff with empty

fixes #12262
fixes #12263

---

 library/Director/ConfigDiff.php |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/library/Director/ConfigDiff.php b/library/Director/ConfigDiff.php
index c1bb819..0b82d23 100644
--- a/library/Director/ConfigDiff.php
+++ b/library/Director/ConfigDiff.php
@@ -22,10 +22,20 @@ class ConfigDiff
     {
         require_once dirname(__DIR__) . '/vendor/php-diff/lib/Diff.php';
 
-        $this->a = explode("\n", (string) $a);
-        $this->b = explode("\n", (string) $b);
+        if (empty($a)) {
+            $this->a = array();
+        } else {
+            $this->a = explode("\n", (string) $a);
+        }
+
+        if (empty($b)) {
+            $this->b = array();
+        } else {
+            $this->b = explode("\n", (string) $b);
+        }
 
         $options = array(
+            'context' => 5,
             // 'ignoreWhitespace' => true,
             // 'ignoreCase' => true,
         );



More information about the icinga-checkins mailing list