From 72700326a3d95227204f65669f1dacb621ef0b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Wed, 18 Oct 2017 17:59:47 +0200 Subject: [PATCH 1/2] [HttpFoundation] Fix FileBag issue with associative arrays --- .../Component/HttpFoundation/FileBag.php | 5 ++++- .../HttpFoundation/Tests/FileBagTest.php | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php index 722ec2a9c4a92..41f8c9269f49d 100644 --- a/src/Symfony/Component/HttpFoundation/FileBag.php +++ b/src/Symfony/Component/HttpFoundation/FileBag.php @@ -87,7 +87,10 @@ protected function convertFileInformation($file) $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']); } } else { - $file = array_filter(array_map(array($this, 'convertFileInformation'), $file)); + $file = array_map(array($this, 'convertFileInformation'), $file); + if (array_keys($keys) === $keys) { + $file = array_filter($file); + } } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php index 7d2902d325d46..f129191a1a670 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php @@ -62,7 +62,7 @@ public function testShouldSetEmptyUploadedFilesToNull() public function testShouldRemoveEmptyUploadedFilesForMultiUpload() { - $bag = new FileBag(array('file' => array( + $bag = new FileBag(array('files' => array( 'name' => array(''), 'type' => array(''), 'tmp_name' => array(''), @@ -70,7 +70,20 @@ public function testShouldRemoveEmptyUploadedFilesForMultiUpload() 'size' => array(0), ))); - $this->assertSame(array(), $bag->get('file')); + $this->assertSame(array(), $bag->get('files')); + } + + public function testNotShouldRemoveEmptyUploadedFilesForAssociativeArray() + { + $bag = new FileBag(array('files' => array( + 'name' => array('file1' => ''), + 'type' => array('file1' => ''), + 'tmp_name' => array('file1' => ''), + 'error' => array('file1' => UPLOAD_ERR_NO_FILE), + 'size' => array('file1' => 0), + ))); + + $this->assertSame(array('file1' => null), $bag->get('files')); } public function testShouldConvertUploadedFilesWithPhpBug() From ab59cc11011ea86c36e529674ab438ee1b4412a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Wed, 25 Oct 2017 15:51:46 +0200 Subject: [PATCH 2/2] typo --- src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php index f129191a1a670..b1bbba0d3f57c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php @@ -73,7 +73,7 @@ public function testShouldRemoveEmptyUploadedFilesForMultiUpload() $this->assertSame(array(), $bag->get('files')); } - public function testNotShouldRemoveEmptyUploadedFilesForAssociativeArray() + public function testShouldNotRemoveEmptyUploadedFilesForAssociativeArray() { $bag = new FileBag(array('files' => array( 'name' => array('file1' => ''), pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy