Skip to content

Commit dee98e4

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: fix tests on AppVeyor Hungarian typo fix in validators translation [Validator] updated Latvian translation [Validator] Added missing Swedish translations [Mailer] [Notifier] #52264 Update Sendinblue / Brevo API host [Validator] Added missing Estonian translations #51939 fix File constraint tests on 32bit PHP [Form] Skip merging params & files if there are no files in the first place [Translation] Ignore bridges in `.gitattributes` file Add missing Hungarian validator translations Added missing Bosnian translations #51929 Added missing Serbian (sr_Latn) translations Added missing Serbian (sr_Cyrl) translations Hide generated files in GitHub diffs and statistics #51937 - Added missing Danish translations
2 parents 6af3c25 + df8ff7f commit dee98e4

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

Tests/AbstractRequestHandlerTestCase.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\EventDispatcher\EventDispatcher;
1616
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
17+
use Symfony\Component\Form\Extension\Core\Type\TextType;
1718
use Symfony\Component\Form\Form;
1819
use Symfony\Component\Form\FormBuilder;
1920
use Symfony\Component\Form\FormError;
@@ -236,6 +237,24 @@ public function testMergeParamsAndFiles($method)
236237
$this->assertSame($file, $form->get('field2')->getData());
237238
}
238239

240+
public function testIntegerChildren()
241+
{
242+
$form = $this->createForm('root', 'POST', true);
243+
$form->add('0', TextType::class);
244+
$form->add('1', TextType::class);
245+
246+
$this->setRequestData('POST', [
247+
'root' => [
248+
'1' => 'bar',
249+
],
250+
]);
251+
252+
$this->requestHandler->handleRequest($form, $this->request);
253+
254+
$this->assertNull($form->get('0')->getData());
255+
$this->assertSame('bar', $form->get('1')->getData());
256+
}
257+
239258
/**
240259
* @dataProvider methodExceptGetProvider
241260
*/

Util/FormUtil.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,21 @@ public static function isEmpty(mixed $data): bool
4646
*/
4747
public static function mergeParamsAndFiles(array $params, array $files): array
4848
{
49-
$result = [];
49+
if (array_is_list($files)) {
50+
foreach ($files as $value) {
51+
$params[] = $value;
52+
}
53+
54+
return $params;
55+
}
5056

5157
foreach ($params as $key => $value) {
5258
if (\is_array($value) && \is_array($files[$key] ?? null)) {
53-
$value = self::mergeParamsAndFiles($value, $files[$key]);
59+
$params[$key] = self::mergeParamsAndFiles($value, $files[$key]);
5460
unset($files[$key]);
5561
}
56-
if (\is_int($key)) {
57-
$result[] = $value;
58-
} else {
59-
$result[$key] = $value;
60-
}
6162
}
6263

63-
return array_merge($result, $files);
64+
return array_replace($params, $files);
6465
}
6566
}

0 commit comments

Comments
 (0)