Skip to content

Commit 5a1aa07

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: 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 Bump Symfony version to 6.3.7 Update VERSION for 6.3.6 Update CHANGELOG for 6.3.6 Hide generated files in GitHub diffs and statistics #51937 - Added missing Danish translations
2 parents d602863 + dee98e4 commit 5a1aa07

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;
@@ -227,6 +228,24 @@ public function testMergeParamsAndFiles($method)
227228
$this->assertSame($file, $form->get('field2')->getData());
228229
}
229230

231+
public function testIntegerChildren()
232+
{
233+
$form = $this->createForm('root', 'POST', true);
234+
$form->add('0', TextType::class);
235+
$form->add('1', TextType::class);
236+
237+
$this->setRequestData('POST', [
238+
'root' => [
239+
'1' => 'bar',
240+
],
241+
]);
242+
243+
$this->requestHandler->handleRequest($form, $this->request);
244+
245+
$this->assertNull($form->get('0')->getData());
246+
$this->assertSame('bar', $form->get('1')->getData());
247+
}
248+
230249
/**
231250
* @dataProvider methodExceptGetProvider
232251
*/

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)