Skip to content

Commit

Permalink
IBX-7809: Fixed passing locationId instead of contentId when crea…
Browse files Browse the repository at this point in the history
…ting `UserMetadata` criterion from `UserGroupLimitationType` level
  • Loading branch information
konradoboza committed Feb 22, 2024
1 parent aa31bb2 commit 75d8ab1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions eZ/Publish/Core/Limitation/UserGroupLimitationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
namespace eZ\Publish\Core\Limitation;

use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\ContentCreateStruct;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
Expand Down Expand Up @@ -189,10 +190,15 @@ public function getCriterion(APILimitationValue $value, APIUserReference $curren
}

$groupIds = [];
$currentUserLocations = $this->persistence->locationHandler()->loadLocationsByContent($currentUser->getUserId());
if (!empty($currentUserLocations)) {
foreach ($currentUserLocations as $currentUserLocation) {
$groupIds[] = $currentUserLocation->parentId;
$locationHandler = $this->persistence->locationHandler();
$currentUserLocations = $locationHandler->loadLocationsByContent($currentUser->getUserId());
foreach ($currentUserLocations as $currentUserLocation) {
try {
$parentLocation = $locationHandler->load($currentUserLocation->parentId);
$groupIds[] = $parentLocation->contentId;
} catch (NotFoundException $e) {
// there is no need for any action - carrying on with checking other user locations
continue;
}
}

Expand Down

0 comments on commit 75d8ab1

Please sign in to comment.