Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Form] fix Catchable Fatal Error if choices is not an array#17163

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Gladhon wants to merge1 commit intosymfony:2.7fromGladhon:2.7
Closed

Conversation

@Gladhon
Copy link

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR

Since 2.7.8 I got a BC-Break Error

Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\ChoiceType::normalizeLegacyChoices() must be of the type array, null given

normalizeLegacyChoices work only with array, so if choices not an array, just don't try to normlize.

@xabbuh
Copy link
Member

The choice list normalizer does this:

// Harden against NULL values (like in EntityType and ModelType)$choices =null !==$options['choices'] ?$options['choices'] :array();

What about using the same here?

@Gladhon
Copy link
Author

If the choicesNormalizer have to make an array in every case, you're right.
IMHO has the choicesNormalizer to normalize arrays to avoid bc's and leave everything else as it is.

@Gladhon
Copy link
Author

@webmozart@nicolas-grekas
Would be nice to merge these in, cause 2.7.8 is broken

Depends on:
#16685

@nicolas-grekas
Copy link
Member

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure but I thinkassertEquals doesn't make a strict comparison. An assertion will be considered valid if you receivefalse whereas you expectnull (and vice-versa). I suggest to use the proper assertion methods instead for both readability and strict comparison.

$this->assertNull($form->getConfig()->getOption('choices'));$this->assertFalse($form->getConfig()->getOption('multiple'));$this->assertFalse($form->getConfig()->getOption('expanded'));

Copy link
Author

Choose a reason for hiding this comment

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

I will change this as you wish.

@GrahamCampbell
Copy link
Contributor

Surely checking if is null is more correct? If something else is passed that's not null or an array, we want the type error to happen, right?

@Tobion
Copy link
Contributor

This conflicts with#16796. I think#16796 should have been merged in 2.7 and not 2.8 and it also covers this case here.

@nicolas-grekas
Copy link
Member

@Tobion you're right!
@Gladhon can you then cherry-pick the patch in#16796 and keep your test case?

@Gladhon
Copy link
Author

@nicolas-grekas done

@nicolas-grekas
Copy link
Member

@Gladhon it looks like the phpdoc block wasn't formatted correctly (see fabbot's patch) can you please fix it and also squash all the commits in one?

@nicolas-grekasnicolas-grekas changed the titleCatchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\ChoiceType::normalizeLegacyChoices() must be of the type array, null given[Form] fix Catchable Fatal Error if choices is not an arrayDec 30, 2015
@nicolas-grekas
Copy link
Member

Thank you@Gladhon.

nicolas-grekas added a commit that referenced this pull requestDec 30, 2015
…y (Gladhon, nicolas-grekas)This PR was merged into the 2.7 branch.Discussion----------[Form] fix Catchable Fatal Error if choices is not an array| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        |Since 2.7.8 I got a BC-Break ErrorCatchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\ChoiceType::normalizeLegacyChoices() must be of the type array, null givennormalizeLegacyChoices work only with array, so if choices not an array, just don't try to normlize.Commits-------f3c2a9b [Form] fix Catchable Fatal Error if choices is not an array
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@Gladhon@xabbuh@nicolas-grekas@GrahamCampbell@Tobion@hhamon@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp