-
Notifications
You must be signed in to change notification settings - Fork 11.3k
[5.0] Fix Broken File Upload When Submitting A Form Without Selecting A File #6256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -608,6 +608,28 @@ public static function createFromBase(SymfonyRequest $request) | |||
} | |||
|
|||
/** | |||
* Clones a request and overrides some of its parameters. | |||
* | |||
* @param array $query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format this docblock correctly.
@@ -608,6 +608,28 @@ public static function createFromBase(SymfonyRequest $request) | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just ?
/**
* {@inheritdoc}
*/
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
{
$files = array_filter((array) $files);
return parent::duplicate($query, $request, $attributes, $cookies, $files, $server);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
[5.0] Fix Broken File Upload When Submitting A Form Without Selecting A File
Thank you @Eduard44 and @taylorotwell This bug has drives me crazy! eheheheh |
👍 |
This is my attempt at fixing (my first PR) the issue:
[5.0] File upload is broken when submitting a form without selecting a file #6189
Right now I'm overriding Symfony's Request::duplicate function so that it can handle empty file form inputs. Another solution is included in the issue (#6189), which modifies the createFromBase function. Both filter the input array to remove any files that are null.