Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using Filter::unequal() * to match a nullable c… #458

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Icingadb/Common/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function applyRestrictions(Query $query)
) {
$roleFilter->add(
Filter::any(
Filter::unequal('service.id', '*'),
Filter::hasNotValue('service.id'),
$this->parseRestriction($restriction, 'icingadb/filter/services')
)
);
Expand Down
12 changes: 1 addition & 11 deletions library/Icingadb/Widget/Detail/ObjectDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use Icinga\Module\Icingadb\Widget\EmptyState;
use ipl\Web\Widget\HorizontalKeyValue;
use Icinga\Module\Icingadb\Widget\ItemList\CommentList;
use Icinga\Module\Icingadb\Widget\Detail\PerfDataTable;
use Icinga\Module\Icingadb\Widget\PluginOutputContainer;
use Icinga\Module\Icingadb\Widget\ShowMore;
use Icinga\Module\Icingadb\Widget\TagList;
Expand Down Expand Up @@ -477,15 +476,12 @@ protected function getUsersAndUsergroups(): array
{
$users = [];
$usergroups = [];
$groupBy = false;

if ($this->objectType === 'host') {
$objectFilter = Filter::all(
Filter::equal('notification.host_id', $this->object->id),
Filter::unequal('notification.service_id', '*')
Filter::hasNotValue('notification.service_id')
);
$objectFilter->metaData()->set('forceOptimization', false);
$groupBy = true;
} else {
$objectFilter = Filter::equal(
'notification.service_id',
Expand All @@ -497,9 +493,6 @@ protected function getUsersAndUsergroups(): array
$userQuery = User::on($this->getDb());
$userQuery->filter($objectFilter);
$this->applyRestrictions($userQuery);
if ($groupBy) {
$userQuery->getSelectBase()->groupBy(['user.id']);
}

foreach ($userQuery as $user) {
$users[$user->name] = $user;
Expand All @@ -510,9 +503,6 @@ protected function getUsersAndUsergroups(): array
$usergroupQuery = Usergroup::on($this->getDb());
$usergroupQuery->filter($objectFilter);
$this->applyRestrictions($usergroupQuery);
if ($groupBy) {
$userQuery->getSelectBase()->groupBy(['usergroup.id']);
}

foreach ($usergroupQuery as $usergroup) {
$usergroups[$usergroup->name] = $usergroup;
Expand Down