Skip to content

Commit 1797031

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: Adjust PR template [HttpClient] Disable HTTP/2 PUSH by default when using curl Bump Symfony version to 6.4.11 Update VERSION for 6.4.10 Update CHANGELOG for 6.4.10 Bump Symfony version to 5.4.43 Update VERSION for 5.4.42 Update CONTRIBUTORS for 5.4.42 Update CHANGELOG for 5.4.42 [DoctrineBridge] Make `EntityValueResolver` return `null` if a composite ID value is `null`
2 parents b526822 + 24ef8e1 commit 1797031

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ArgumentResolver/EntityValueResolver.php

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ private function find(ObjectManager $manager, Request $request, MapEntity $optio
104104
if (false === $id || null === $id) {
105105
return $id;
106106
}
107+
if (\is_array($id) && \in_array(null, $id, true)) {
108+
return null;
109+
}
107110

108111
if ($options->evictCache && $manager instanceof EntityManagerInterface) {
109112
$cacheProvider = $manager->getCache();

Tests/ArgumentResolver/EntityValueResolverTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ public function testResolveWithNullId()
139139
$this->assertSame([null], $resolver->resolve($request, $argument));
140140
}
141141

142+
public function testResolveWithArrayIdNullValue()
143+
{
144+
$manager = $this->createMock(ObjectManager::class);
145+
$registry = $this->createRegistry($manager);
146+
$resolver = new EntityValueResolver($registry);
147+
148+
$request = new Request();
149+
$request->attributes->set('nullValue', null);
150+
151+
$argument = $this->createArgument(entity: new MapEntity(id: ['nullValue']), isNullable: true,);
152+
153+
$this->assertSame([null], $resolver->resolve($request, $argument));
154+
}
155+
142156
public function testResolveWithConversionFailedException()
143157
{
144158
$manager = $this->getMockBuilder(ObjectManager::class)->getMock();

0 commit comments

Comments
 (0)