Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6cd50ad

Browse filesBrowse files
committed
bug #42112 [HttpFoundation] fix FileBag under PHP 8.1 (alexpott)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpFoundation] fix FileBag under PHP 8.1 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no<!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> See https://php.watch/versions/8.1/$_FILES-full-path - in \Symfony\Component\HttpFoundation\FileBag::convertFileInformation() we check against a list of hardcoded keys. This logic breaks in PHP 8.1 because of the new key. Commits ------- dc35049 [HttpFoundation] fix FileBag under PHP 8.1
2 parents 6b2b7b9 + dc35049 commit 6cd50ad
Copy full SHA for 6cd50ad

File tree

2 files changed

+19
-0
lines changed
Filter options

2 files changed

+19
-0
lines changed

‎src/Symfony/Component/HttpFoundation/FileBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/FileBag.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ protected function convertFileInformation($file)
113113
*/
114114
protected function fixPhpFilesArray($data)
115115
{
116+
// Remove extra key added by PHP 8.1.
117+
unset($data['full_path']);
116118
$keys = array_keys($data);
117119
sort($keys);
118120

‎src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ public function testShouldConvertsUploadedFiles()
4545
$this->assertEquals($file, $bag->get('file'));
4646
}
4747

48+
public function testShouldConvertsUploadedFilesPhp81()
49+
{
50+
$tmpFile = $this->createTempFile();
51+
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
52+
53+
$bag = new FileBag(['file' => [
54+
'name' => basename($tmpFile),
55+
'full_path' => basename($tmpFile),
56+
'type' => 'text/plain',
57+
'tmp_name' => $tmpFile,
58+
'error' => 0,
59+
'size' => null,
60+
]]);
61+
62+
$this->assertEquals($file, $bag->get('file'));
63+
}
64+
4865
public function testShouldSetEmptyUploadedFilesToNull()
4966
{
5067
$bag = new FileBag(['file' => [

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.