From 2790711b3acec018c671af54e77d195e3ae69de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Wed, 21 Apr 2021 14:58:52 +0200 Subject: [PATCH 1/2] IBX-251: Replaced eZ\Publish\API\Repository\ContentService::loadReverseRelations usages --- src/bundle/Controller/ContentViewController.php | 9 +++++---- .../Specification/Content/ContentHaveUniqueRelation.php | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bundle/Controller/ContentViewController.php b/src/bundle/Controller/ContentViewController.php index 05b30d4ff7..78df08704f 100644 --- a/src/bundle/Controller/ContentViewController.php +++ b/src/bundle/Controller/ContentViewController.php @@ -557,13 +557,14 @@ private function supplyIsLocationBookmarked(ContentView $view): void private function supplyContentReverseRelations(ContentView $view): void { $contentInfo = $view->getLocation()->getContentInfo(); - $relations = $this->permissionResolver->sudo( - function (Repository $repository) use ($contentInfo) { - return $repository->getContentService()->loadReverseRelations($contentInfo); + + $hasReverseRelations = $this->permissionResolver->sudo( + static function (Repository $repository) use ($contentInfo): bool { + return $repository->getContentService()->countReverseRelations($contentInfo) > 0; }, $this->repository ); - $view->addParameters(['content_has_reverse_relations' => \count($relations) > 0]); + $view->addParameters(['content_has_reverse_relations' => $hasReverseRelations]); } } diff --git a/src/lib/Specification/Content/ContentHaveUniqueRelation.php b/src/lib/Specification/Content/ContentHaveUniqueRelation.php index 5011a025f0..b80c7d95bd 100644 --- a/src/lib/Specification/Content/ContentHaveUniqueRelation.php +++ b/src/lib/Specification/Content/ContentHaveUniqueRelation.php @@ -45,9 +45,11 @@ public function isSatisfiedBy($item): bool foreach ($relations as $relation) { if (Relation::ASSET === $relation->type) { - $relationsFromAssetSide = $this->contentService->loadReverseRelations($relation->destinationContentInfo); + $relationsFromAssetSide = $this->contentService->countReverseRelations( + $relation->destinationContentInfo + ); - if (count($relationsFromAssetSide) > 1) { + if ($relationsFromAssetSide > 1) { return false; } } From cea6d1fddbb23781f9b7f82254aea29d599fbc6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Wed, 21 Apr 2021 15:19:02 +0200 Subject: [PATCH 2/2] Trigger CI