Skip to content

Commit befd9ba

Browse files
committed
Fix the normalization context passed to EagerLoadingExtension::joinRelations()
1 parent da84be3 commit befd9ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ private function apply(bool $collection, QueryBuilder $queryBuilder, QueryNameGe
102102
$forceEager = $this->shouldOperationForceEager($resourceClass, $options);
103103
$fetchPartial = $this->shouldOperationFetchPartial($resourceClass, $options);
104104

105-
if (!isset($context['groups']) && !isset($context['attributes'])) {
106-
$contextType = isset($context['api_denormalize']) ? 'denormalization_context' : 'normalization_context';
107-
$context += $this->getNormalizationContext($context['resource_class'] ?? $resourceClass, $contextType, $options);
105+
$contextType = isset($context['api_denormalize']) ? 'denormalization_context' : 'normalization_context';
106+
$normalizationContext = $context[$contextType] ?? [];
107+
108+
if (!isset($normalizationContext['groups']) && !isset($normalizationContext['attributes'])) {
109+
$normalizationContext += $this->getNormalizationContext($context['resource_class'] ?? $resourceClass, $contextType, $options);
108110
}
109111

110-
$this->joinRelations($queryBuilder, $queryNameGenerator, $resourceClass, $forceEager, $fetchPartial, $queryBuilder->getRootAliases()[0], $options, $context);
112+
$this->joinRelations($queryBuilder, $queryNameGenerator, $resourceClass, $forceEager, $fetchPartial, $queryBuilder->getRootAliases()[0], $options, $normalizationContext);
111113
}
112114

113115
/**

0 commit comments

Comments
 (0)