[icinga-checkins] icinga.org: icingaweb2/master: DbConnection: Don' t ignore asterisks when rendering filters

git at icinga.org git at icinga.org
Fri Nov 11 09:20:12 CET 2016


Module: icingaweb2
Branch: master
Commit: 3a619eb8c72b9570039dede58b4ff3279b23d00c
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=3a619eb8c72b9570039dede58b4ff3279b23d00c

Author: Johannes Meyer <johannes.meyer at netways.de>
Date:   Fri Nov 11 09:18:53 2016 +0100

DbConnection: Don't ignore asterisks when rendering filters

refs #11885

---

 library/Icinga/Data/Db/DbConnection.php |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/library/Icinga/Data/Db/DbConnection.php b/library/Icinga/Data/Db/DbConnection.php
index 9705bff..e1068f7 100644
--- a/library/Icinga/Data/Db/DbConnection.php
+++ b/library/Icinga/Data/Db/DbConnection.php
@@ -9,8 +9,8 @@ use Icinga\Data\Inspection;
 use PDO;
 use Iterator;
 use Zend_Db;
+use Zend_Db_Expr;
 use Icinga\Data\ConfigObject;
-use Icinga\Data\Db\DbQuery;
 use Icinga\Data\Extensible;
 use Icinga\Data\Filter\Filter;
 use Icinga\Data\Filter\FilterAnd;
@@ -452,10 +452,10 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
             );
         } elseif ($sign === '=' && strpos($value, '*') !== false) {
             if ($value === '*') {
-                // We'll ignore such filters as it prevents index usage and because "*" means anything, anything means
-                // all whereas all means that whether we use a filter to match anything or no filter at all makes no
-                // difference, except for performance reasons...
-                return '';
+                // We'll ignore such filters as it prevents index usage and because "*" means anything, so whether we're
+                // using a real column with a valid comparison here or just an expression which can only be evaluated to
+                // true makes no difference, except for performance reasons...
+                return new Zend_Db_Expr('TRUE');
             }
 
             return $column . ' LIKE ' . $this->dbAdapter->quote(preg_replace('~\*~', '%', $value));
@@ -464,7 +464,7 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
                 // We'll ignore such filters as it prevents index usage and because "*" means nothing, so whether we're
                 // using a real column with a valid comparison here or just an expression which cannot be evaluated to
                 // true makes no difference, except for performance reasons...
-                return $this->dbAdapter->quote(0);
+                return new Zend_Db_Expr('FALSE');
             }
 
             return sprintf(



More information about the icinga-checkins mailing list