[icinga-checkins] icinga.org: icinga-api/master: * Removing double 'and' in filters

git at icinga.org git at icinga.org
Thu Sep 9 16:57:56 CEST 2010


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Thu Sep  9 16:57:38 2010 +0200

* Removing double 'and' in filters

---

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

diff --git a/objects/search/IcingaApiSearchIdo.php b/objects/search/IcingaApiSearchIdo.php
index c7f3cbd..b76d048 100644
--- a/objects/search/IcingaApiSearchIdo.php
+++ b/objects/search/IcingaApiSearchIdo.php
@@ -488,10 +488,11 @@ class IcingaApiSearchIdo
 
 			// add custom filter to append
 			$filterStatement .= $this->getFilterAppendix();
-
+			
 			// replace query variable by filter
 			$query = str_replace('${FILTER}', ($filterStatement ? " WHERE " : '').$filterStatement, $query);
-			$query = str_replace('${FILTER_AND}', ($filterStatement ? "AND " : '').$filterStatement, $query);
+			
+			$query = str_replace('${FILTER_AND}', ($filterStatement && !preg_match('/^\s*and\s+/i', $filterStatement) ? "AND " : '').$filterStatement, $query);
 
 			// add 'group by'
 			$query = $this->replaceQueryVariables($query, 'GROUPBY');





More information about the icinga-checkins mailing list