[icinga-checkins] icinga.org: icinga-api/r1.2: * Remove AND|OR if no other WHERE is available

git at icinga.org git at icinga.org
Wed Nov 3 15:14:47 CET 2010


Module: icinga-api
Branch: r1.2
Commit: b59d3e15d6aede24d0c21797b807fb4037330741
URL:    https://git.icinga.org/?p=icinga-api.git;a=commit;h=b59d3e15d6aede24d0c21797b807fb4037330741

Author: Marius Hein <marius.hein at netways.de>
Date:   Wed Nov  3 15:13:50 2010 +0100

* Remove AND|OR if no other WHERE is available

---

 objects/search/IcingaApiSearchIdo.php |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/objects/search/IcingaApiSearchIdo.php b/objects/search/IcingaApiSearchIdo.php
index 3967a98..ad853d9 100644
--- a/objects/search/IcingaApiSearchIdo.php
+++ b/objects/search/IcingaApiSearchIdo.php
@@ -488,10 +488,16 @@ class IcingaApiSearchIdo
 				$filterStatement = null;
 				$queryValues = array();
 			}
-
-			// add custom filter to append
-			$filterStatement .= $this->getFilterAppendix();
 			
+			// add custom filter to append
+			$appendix = $this->getFilterAppendix();
+			if (!$filterStatement) {
+				// Remove some useless things at the beginning
+				$appendix = preg_replace('/^\s*(and|or)\s+/i', '', $appendix);
+			}
+
+			$filterStatement .= $appendix;
+	
 			// replace query variable by filter
 			$query = str_replace('${FILTER}', ($filterStatement ? " WHERE " : '').$filterStatement, $query);
 			





More information about the icinga-checkins mailing list