mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-16 18:34:26 +02:00
Merge pull request #3917 from Icinga/fix/flawed-group-filter-chains-3916
Fix flawed group filter chains
This commit is contained in:
commit
cc19e68dfb
@ -312,17 +312,19 @@ class DbQuery extends SimpleQuery
|
|||||||
if (! empty($comp)) {
|
if (! empty($comp)) {
|
||||||
$sql[] = $col . ' IN (' . $this->escapeForSql($comp) . ')';
|
$sql[] = $col . ' IN (' . $this->escapeForSql($comp) . ')';
|
||||||
}
|
}
|
||||||
|
$operator = 'OR';
|
||||||
} elseif ($sign === '!=') {
|
} elseif ($sign === '!=') {
|
||||||
if (! empty($comp)) {
|
if (! empty($comp)) {
|
||||||
$sql[] = sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $col, $this->escapeForSql($comp));
|
$sql[] = sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $col, $this->escapeForSql($comp));
|
||||||
}
|
}
|
||||||
|
$operator = 'AND';
|
||||||
} else {
|
} else {
|
||||||
throw new QueryException(
|
throw new QueryException(
|
||||||
'Unable to render array expressions with operators other than equal or not equal'
|
'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) {
|
} elseif ($sign === '=' && strpos($expression, '*') !== false) {
|
||||||
if ($expression === '*') {
|
if ($expression === '*') {
|
||||||
return new Zend_Db_Expr('TRUE');
|
return new Zend_Db_Expr('TRUE');
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
use Icinga\Exception\NotImplementedError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host groups
|
* Query for host groups
|
||||||
*/
|
*/
|
||||||
@ -276,13 +274,8 @@ class HostgroupQuery extends IdoQuery
|
|||||||
protected function joinSubQuery(IdoQuery $query, $name, $filter, $and, $negate, &$additionalFilter)
|
protected function joinSubQuery(IdoQuery $query, $name, $filter, $and, $negate, &$additionalFilter)
|
||||||
{
|
{
|
||||||
if ($name === 'hostgroup') {
|
if ($name === 'hostgroup') {
|
||||||
if (! $and) {
|
// Propagate that the "parent" query has to be filtered as well
|
||||||
// IN AND NOT IN works for OR filters w/o subquery joins
|
$additionalFilter = clone $filter;
|
||||||
throw new NotImplementedError('');
|
|
||||||
} else {
|
|
||||||
// Propagate that the "parent" query has to be filtered as well
|
|
||||||
$additionalFilter = clone $filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->requireVirtualTable('members');
|
$this->requireVirtualTable('members');
|
||||||
|
|
||||||
|
@ -633,6 +633,12 @@ abstract class IdoQuery extends DbQuery
|
|||||||
new Zend_Db_Expr($ours)
|
new Zend_Db_Expr($ours)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if (! $negate) {
|
||||||
|
$subQueryFilter = $subQueryFilter->orFilter(
|
||||||
|
new FilterExpression($ours, '', new Zend_Db_Expr('IS NULL'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$subQuery
|
$subQuery
|
||||||
->setFilter($subQueryFilter)
|
->setFilter($subQueryFilter)
|
||||||
->clearGroupingRules()
|
->clearGroupingRules()
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
use Icinga\Exception\NotImplementedError;
|
|
||||||
|
|
||||||
class ServicegroupQuery extends IdoQuery
|
class ServicegroupQuery extends IdoQuery
|
||||||
{
|
{
|
||||||
protected $groupBase = array(
|
protected $groupBase = array(
|
||||||
@ -290,13 +288,8 @@ class ServicegroupQuery extends IdoQuery
|
|||||||
|
|
||||||
return ['so.object_id', 'so.object_id'];
|
return ['so.object_id', 'so.object_id'];
|
||||||
} elseif ($name === 'servicegroup') {
|
} elseif ($name === 'servicegroup') {
|
||||||
if (! $and) {
|
// Propagate that the "parent" query has to be filtered as well
|
||||||
// IN AND NOT IN for OR filters works w/o subquery joins
|
$additionalFilter = clone $filter;
|
||||||
throw new NotImplementedError('');
|
|
||||||
} else {
|
|
||||||
// Propagate that the "parent" query has to be filtered as well
|
|
||||||
$additionalFilter = clone $filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->requireVirtualTable('members');
|
$this->requireVirtualTable('members');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user