-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Symfony version(s) affected: 5.2.0
Description
This is my first bug report, so please let me know if I did something incorrectly.
The change did within symfony/mime@8239e12 allows multiple parts with the same name in FormDataPart, but it fails to allow usage of multiple DataPart values, with exception message Form field values with integer keys can only have one array element, the key being the field name and the value being the field value
...
This used to work before upgrading to 5.2, as I have been using it just fine for the last past 9 months, based on an example from Sylius' tests https://github.com/Sylius/Sylius/blob/master/tests/Controller/ProductApiTest.php#L508
How to reproduce
I added a new test into FormDataPartTest.php and it passes with 5.1 while it fails on 5.2.
public function testFormFieldsWithIntegerKeysAndMultipleUploadedFiles()
{
$f = new FormDataPart([
[
new DataPart($foo = str_repeat('foo', 1000), 'foo.txt', 'text/plain'),
new DataPart($bar = str_repeat('bar', 1000), 'bar.txt', 'text/plain'),
],
]);
$parts = $f->getParts();
$this->assertEquals($foo, $parts[0]->bodyToString());
$this->assertEquals($bar, $parts[1]->bodyToString());
}
Additional context
The issue where this change was described is #38258 and is based on an array of TextPart values.