Skip to content

Commit ca4ec82

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

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

library/Icinga/Data/Db/DbConnection.php

Lines changed: 12 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,23 @@ 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 (
583+
$sign === '='
584+
&& ! $filter instanceof FilterEqual
585+
&& $value !== null
586+
&& strpos($value, '*') !== false
587+
) {
586588
if ($value === '*') {
587589
return $column . ' IS NOT NULL';
588590
}
589591

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

0 commit comments

Comments
 (0)