From c8ed889114c856c894a82b7c9ca388229d29f4a7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 13 Aug 2019 17:19:45 +0200 Subject: [PATCH] Fix operator in wildcard filter chains --- library/Icinga/Data/Db/DbQuery.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php index 25de96742..fffd7b08a 100644 --- a/library/Icinga/Data/Db/DbQuery.php +++ b/library/Icinga/Data/Db/DbQuery.php @@ -312,17 +312,19 @@ class DbQuery extends SimpleQuery if (! empty($comp)) { $sql[] = $col . ' IN (' . $this->escapeForSql($comp) . ')'; } + $operator = 'OR'; } elseif ($sign === '!=') { if (! empty($comp)) { $sql[] = sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $col, $this->escapeForSql($comp)); } + $operator = 'AND'; } else { throw new QueryException( 'Unable to render array expressions with operators other than equal or not equal' ); } - return '(' . implode(' OR ', $sql) . ')'; + return '(' . implode(" $operator ", $sql) . ')'; } elseif ($sign === '=' && strpos($expression, '*') !== false) { if ($expression === '*') { return new Zend_Db_Expr('TRUE');