Skip to content

Commit

Permalink
Merge branch '6.4' into 7.1
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
xabbuh committed Jul 30, 2024
2 parents b526822 + 24ef8e1 commit 1797031
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ArgumentResolver/EntityValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ private function find(ObjectManager $manager, Request $request, MapEntity $optio
if (false === $id || null === $id) {
return $id;
}
if (\is_array($id) && \in_array(null, $id, true)) {
return null;
}

if ($options->evictCache && $manager instanceof EntityManagerInterface) {
$cacheProvider = $manager->getCache();
Expand Down
14 changes: 14 additions & 0 deletions Tests/ArgumentResolver/EntityValueResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ public function testResolveWithNullId()
$this->assertSame([null], $resolver->resolve($request, $argument));
}

public function testResolveWithArrayIdNullValue()
{
$manager = $this->createMock(ObjectManager::class);
$registry = $this->createRegistry($manager);
$resolver = new EntityValueResolver($registry);

$request = new Request();
$request->attributes->set('nullValue', null);

$argument = $this->createArgument(entity: new MapEntity(id: ['nullValue']), isNullable: true,);

$this->assertSame([null], $resolver->resolve($request, $argument));
}

public function testResolveWithConversionFailedException()
{
$manager = $this->getMockBuilder(ObjectManager::class)->getMock();
Expand Down

0 comments on commit 1797031

Please sign in to comment.