Skip to content

Commit d663fe8

Browse files
committed
DbConnection: Fix that unequal is handled as equal...
refs #4814
1 parent 1bee2db commit d663fe8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

library/Icinga/Data/Db/DbConnection.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,6 @@ protected function renderFilterExpression(Filter $filter)
544544
$sign = $filter->getSign();
545545
$value = $filter->getExpression();
546546

547-
$matchWildcard = $sign === '=' && ! $filter instanceof FilterEqual
548-
|| $sign === '!=' && ! $filter instanceof FilterNotEqual;
549-
550547
if (is_array($value)) {
551548
$comp = [];
552549
$pattern = [];
@@ -582,13 +579,21 @@ protected function renderFilterExpression(Filter $filter)
582579
}
583580

584581
return count($sql) === 1 ? $sql[0] : '(' . implode(" $operator ", $sql) . ')';
585-
} elseif ($matchWildcard && $value !== null && strpos($value, '*') !== false) {
582+
} elseif ($sign === '='
583+
&& ! $filter instanceof FilterEqual
584+
&& $value !== null
585+
&& strpos($value, '*') !== false
586+
) {
586587
if ($value === '*') {
587588
return $column . ' IS NOT NULL';
588589
}
589590

590591
return $column . ' LIKE ' . $this->dbAdapter->quote(preg_replace('~\*~', '%', $value));
591-
} elseif ($matchWildcard && $value !== null && strpos($value, '*') !== false) {
592+
} elseif ($sign === '!='
593+
&& ! $filter instanceof FilterNotEqual
594+
&& $value !== null
595+
&& strpos($value, '*') !== false
596+
) {
592597
if ($value === '*') {
593598
return $column . ' IS NULL';
594599
}

0 commit comments

Comments
 (0)