[icinga-checkins] icinga.org: icingaweb2/feature/announce-banner-11198: IniRepository: Fix that method update and delete fail without filter

git at icinga.org git at icinga.org
Fri Oct 28 17:48:30 CEST 2016


Module: icingaweb2
Branch: feature/announce-banner-11198
Commit: f6448605298666b1ca53888b11cb62adc2945d6f
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=f6448605298666b1ca53888b11cb62adc2945d6f

Author: Johannes Meyer <johannes.meyer at netways.de>
Date:   Thu Oct 27 15:09:00 2016 +0200

IniRepository: Fix that method update and delete fail without filter


---

 library/Icinga/Repository/IniRepository.php |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/library/Icinga/Repository/IniRepository.php b/library/Icinga/Repository/IniRepository.php
index 8cc961c..8ff1936 100644
--- a/library/Icinga/Repository/IniRepository.php
+++ b/library/Icinga/Repository/IniRepository.php
@@ -93,15 +93,12 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
             );
         }
 
+        $query = $this->ds->select();
         if ($filter !== null) {
-            $filter = $this->requireFilter($target, $filter);
+            $query->addFilter($this->requireFilter($target, $filter));
         }
 
         $newSection = null;
-
-        $query = $this->ds->select();
-        $query->addFilter($filter);
-
         foreach ($query as $section => $config) {
             if ($newSection !== null) {
                 throw new StatementException(
@@ -149,17 +146,15 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
      */
     public function delete($target, Filter $filter = null)
     {
+        $query = $this->ds->select();
         if ($filter !== null) {
-            $filter = $this->requireFilter($target, $filter);
+            $query->addFilter($this->requireFilter($target, $filter));
         }
 
-        $query = $this->ds->select();
-        $query->addFilter($filter);
-
         foreach ($query as $section => $config) {
             $this->ds->removeSection($section);
         }
-        
+
         try {
             $this->ds->saveIni();
         } catch (Exception $e) {



More information about the icinga-checkins mailing list