Skip to content

Commit 0cc1d00

Browse files
Merge branch '3.4' into 4.4
* 3.4: [FrameworkBundle] fix "samesite" in XSD Update UserPasswordEncoderCommand.php [HttpFoundation][FrameworkBundle] fix support for samesite in session cookies [DoctrineBridge] Fixed submitting ids with query limit or offset
2 parents b8d4311 + ab4a513 commit 0cc1d00

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getEntitiesByIds($identifier, array $values)
5757
$metadata = $this->queryBuilder->getEntityManager()->getClassMetadata(current($this->queryBuilder->getRootEntities()));
5858

5959
foreach ($this->getEntities() as $entity) {
60-
if (\in_array(current($metadata->getIdentifierValues($entity)), $values, true)) {
60+
if (\in_array((string) current($metadata->getIdentifierValues($entity)), $values, true)) {
6161
$choices[] = $entity;
6262
}
6363
}

Tests/Form/Type/EntityTypeTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,32 @@ public function testDisallowChoicesThatAreNotIncludedQueryBuilderSingleIdentifie
953953
$this->assertNull($field->getData());
954954
}
955955

956-
public function testDisallowChoicesThatAreNotIncludedQueryBuilderSingleIdentifierWithLimit()
956+
public function testSingleIdentifierWithLimit()
957+
{
958+
$entity1 = new SingleIntIdEntity(1, 'Foo');
959+
$entity2 = new SingleIntIdEntity(2, 'Bar');
960+
$entity3 = new SingleIntIdEntity(3, 'Baz');
961+
962+
$this->persist([$entity1, $entity2, $entity3]);
963+
964+
$repository = $this->em->getRepository(self::SINGLE_IDENT_CLASS);
965+
966+
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
967+
'em' => 'default',
968+
'class' => self::SINGLE_IDENT_CLASS,
969+
'query_builder' => $repository->createQueryBuilder('e')
970+
->where('e.id IN (1, 2, 3)')
971+
->setMaxResults(1),
972+
'choice_label' => 'name',
973+
]);
974+
975+
$field->submit('1');
976+
977+
$this->assertTrue($field->isSynchronized());
978+
$this->assertSame($entity1, $field->getData());
979+
}
980+
981+
public function testDisallowChoicesThatAreNotIncludedByQueryBuilderSingleIdentifierWithLimit()
957982
{
958983
$entity1 = new SingleIntIdEntity(1, 'Foo');
959984
$entity2 = new SingleIntIdEntity(2, 'Bar');

0 commit comments

Comments
 (0)