From fee45a24386a60619b582fdc1b494a05d547b8db Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 2 Jun 2016 17:27:32 +0200 Subject: [PATCH] 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 72c9b7743..48607b66d 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));