[icinga-checkins] icinga.org: icingaweb2/master: Database: Never ignore asterisk filters

git at icinga.org git at icinga.org
Thu Jun 2 17:28:03 CEST 2016


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

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Thu Jun  2 17:27:32 2016 +0200

Database: Never ignore asterisk filters

fixes #11885

---

 library/Icinga/Data/Db/DbQuery.php |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php
index 72c9b77..48607b6 100644
--- a/library/Icinga/Data/Db/DbQuery.php
+++ b/library/Icinga/Data/Db/DbQuery.php
@@ -4,6 +4,7 @@
 namespace Icinga\Data\Db;
 
 use Exception;
+use Zend_Db_Expr;
 use Zend_Db_Select;
 use Icinga\Application\Logger;
 use Icinga\Data\Filter\FilterAnd;
@@ -306,19 +307,13 @@ class DbQuery extends SimpleQuery
             throw new QueryException('Unable to render array expressions with operators other than equal or not equal');
         } elseif ($sign === '=' && strpos($expression, '*') !== false) {
             if ($expression === '*') {
-                // 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 '';
+                return new Zend_Db_Expr('TRUE');
             }
 
             return $col . ' LIKE ' . $this->escapeForSql($this->escapeWildcards($expression));
         } elseif ($sign === '!=' && strpos($expression, '*') !== false) {
             if ($expression === '*') {
-                // 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->escapeForSql(0);
+                return new Zend_Db_Expr('FALSE');
             }
 
             return $col . ' NOT LIKE ' . $this->escapeForSql($this->escapeWildcards($expression));



More information about the icinga-checkins mailing list