From 0b9d95b92ac545f2ebb2e6de2e5d7a1ad13748c7 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Mon, 25 Mar 2024 17:24:32 +0100 Subject: [PATCH] IBX-8019: Refactored Object State Id criterion --- .../Core/Limitation/ObjectStateLimitationType.php | 8 +------- .../Content/ObjectStateIdQueryBuilder.php | 10 ++++------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/eZ/Publish/Core/Limitation/ObjectStateLimitationType.php b/eZ/Publish/Core/Limitation/ObjectStateLimitationType.php index 28aa2fa218..32278ba5ff 100644 --- a/eZ/Publish/Core/Limitation/ObjectStateLimitationType.php +++ b/eZ/Publish/Core/Limitation/ObjectStateLimitationType.php @@ -225,13 +225,7 @@ public function getCriterion(APILimitationValue $value, APIUserReference $curren return new Criterion\ObjectStateId($groupedLimitationValues[0]); } - // limitations from different groups require logical AND between them - $criterions = []; - foreach ($groupedLimitationValues as $limitationGroup) { - $criterions[] = new Criterion\ObjectStateId($limitationGroup); - } - - return new Criterion\LogicalAnd($criterions); + return new Criterion\ObjectStateId($value->limitationValues); } /** diff --git a/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php b/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php index a189f42847..fcb0f5821d 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php +++ b/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php @@ -29,21 +29,19 @@ public function buildQueryConstraint( FilteringQueryBuilder $queryBuilder, FilteringCriterion $criterion ): ?string { - $tableAlias = uniqid('osl_'); - /** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ObjectStateId $criterion */ $queryBuilder - ->join( + ->joinOnce( 'content', Gateway::OBJECT_STATE_LINK_TABLE, - $tableAlias, - 'content.id = ' . $tableAlias . '.contentobject_id', + 'object_state_link', + 'content.id = object_state_link.contentobject_id', ); $value = (array)$criterion->value; return $queryBuilder->expr()->in( - $tableAlias . '.contentobject_state_id', + 'object_state_link.contentobject_state_id', $queryBuilder->createNamedParameter($value, Connection::PARAM_INT_ARRAY) ); }