Skip to content

Commit

Permalink
fix(saved search): entities restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B authored Feb 14, 2024
1 parent 625cb0b commit 7d07d1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -1409,12 +1409,12 @@ private static function getVisibilityCriteriaForMine(): array
$restrict = [
'OR' => [
$restrict,
[self::getTable() . '.is_private' => 0] + getEntitiesRestrictCriteria(self::getTable(), '', '', true)
[self::getTable() . '.is_private' => 0]
]
];
}

$criteria['WHERE'] = $restrict;
$criteria['WHERE'] = $restrict + getEntitiesRestrictCriteria(self::getTable(), '', '', true);
return $criteria;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testAddVisibilityRestrict()
// Check entity restriction
$this->setEntity('_test_root_entity', true);
$this->string(\SavedSearch::addVisibilityRestrict())
->isIdenticalTo("((`glpi_savedsearches`.`is_private` = '1' AND `glpi_savedsearches`.`users_id` = '5') OR (`glpi_savedsearches`.`is_private` = '0' AND ((`glpi_savedsearches`.`entities_id` IN ({$_SESSION['glpiactiveentities_string']}) OR (`glpi_savedsearches`.`is_recursive` = '1' AND `glpi_savedsearches`.`entities_id` IN ('0'))))))");
->isIdenticalTo("((`glpi_savedsearches`.`is_private` = '1' AND `glpi_savedsearches`.`users_id` = '5') OR (`glpi_savedsearches`.`is_private` = '0')) AND ((`glpi_savedsearches`.`entities_id` IN ('1', '2', '3') OR (`glpi_savedsearches`.`is_recursive` = '1' AND `glpi_savedsearches`.`entities_id` IN ('0'))))");
}

public function testGetMine()
Expand Down

0 comments on commit 7d07d1e

Please sign in to comment.