Skip to content

[Form] Fixed ContextErrorException in FileType #25102

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

Closed
wants to merge 2 commits into from

Conversation

chihiro-adachi
Copy link

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #25063
License MIT
Doc PR --

Fixed an issue that ContextErrorException occurs when multiple is enabled.


foreach ($event->getData() as $file) {
if (!is_array($files)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about checking for null here first and then dropping everything afterwards that is not an array?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe just:

if (!is_array($files)) {
    $files = array(null);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh Thank you, I fixed it.

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Nov 22, 2017

foreach ($event->getData() as $file) {
if (!is_array($files)) {
$files = array(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$files = array(); also looks more better to me, it reduces the redundant traverse over them and RequestHandlerInterface::isFileUpload() method call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed while merging

@nicolas-grekas
Copy link
Member

Thank you @chihiro-adachi.

nicolas-grekas added a commit that referenced this pull request Nov 23, 2017
…achi)

This PR was squashed before being merged into the 2.7 branch (closes #25102).

Discussion
----------

[Form] Fixed ContextErrorException in FileType

| Q             | A
| ------------- | ---
| Branch?       |  2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25063
| License       | MIT
| Doc PR        | --

Fixed an issue that ContextErrorException occurs when multiple is enabled.

Commits
-------

1b408e6 [Form] Fixed ContextErrorException in FileType
@chihiro-adachi chihiro-adachi deleted the fix-file-type branch November 24, 2017 00:18
This was referenced Nov 24, 2017
This was referenced Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants