From 7d07d1ef0448791073cf4aafc9b0c9b308c3a6a6 Mon Sep 17 00:00:00 2001 From: Romain B <8530352+Rom1-B@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:12:51 +0100 Subject: [PATCH] fix(saved search): entities restriction --- src/SavedSearch.php | 4 ++-- tests/functional/SavedSearch.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SavedSearch.php b/src/SavedSearch.php index cd507859a38..385babd61ce 100644 --- a/src/SavedSearch.php +++ b/src/SavedSearch.php @@ -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; } diff --git a/tests/functional/SavedSearch.php b/tests/functional/SavedSearch.php index 0552262d383..a3af5578aa5 100644 --- a/tests/functional/SavedSearch.php +++ b/tests/functional/SavedSearch.php @@ -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()