8000 Fix the retrieval of the value with property path when using a loader by stof · Pull Request #15623 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fix the retrieval of the value with property path when using a loader #15623

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

Merged
merged 1 commit into from
Aug 26, 2015

Conversation

stof
Copy link
Member
@stof stof commented Aug 26, 2015
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

the ChoiceType is transforming the form data to its value in case of non-expanded fields.

When creating the choice list from choices, this works fine when using a property path for the choice_value, because it has a safeguard against values which are not object or arrays (a typical case being null because nothing is selected yet).
However, when loading from a ChoiceLoader, the generated closure was missing the same safeguard, breaking the usage of ChoiceLoader with property path.
This went unnoticed because the only usage of choice_loader in core is for the doctrine type, and this one uses its own logic to get the choice value

I added test on the PropertyAccessDecorator directly, to have fast tests. We could imagine adding tests in the ChoiceTypeTest using a ChoiceLoader too, matching all existing tests for other ways to specify arguments, but I'm not sure it is worth it.

@Tobion
Copy link
Contributor
Tobion commented Aug 26, 2015

CS fixes need to be done, see fabbot

@Tobion
Copy link
Contributor
Tobion commented Aug 26, 2015

👍

@stof
Copy link
Member Author
stof commented Aug 26, 2015

@fabpot the URL of the Symfony documentation about the PR contribution header should be a link on fabbot report pages, to make it easier to access them.

@stof stof force-pushed the fix_property_access_decorator branch from 5bee5dc to 5df64dc Compare August 26, 2015 16:42
@stof
Copy link
Member Author
stof commented Aug 26, 2015

CS fixes are done

@Tobion
Copy link
Contributor
Tobion commented Aug 26, 2015

Thank you @stof.

@Tobion Tobion merged commit 5df64dc into symfony:2.7 Aug 26, 2015
Tobion added a commit that referenced this pull request Aug 26, 2015
…ng a loader (stof)

This PR was merged into the 2.7 branch.

Discussion
----------

Fix the retrieval of the value with property path when using a loader

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

the ChoiceType is transforming the form data to its value in case of non-expanded fields.

When creating the choice list from choices, this works fine when using a property path for the choice_value, because it has a safeguard against values which are not object or arrays (a typical case being ``null`` because nothing is selected yet).
However, when loading from a ChoiceLoader, the generated closure was missing the same safeguard, breaking the usage of ChoiceLoader with property path.
This went unnoticed because the only usage of choice_loader in core is for the doctrine type, and this one uses its own logic to get the choice value

I added test on the PropertyAccessDecorator directly, to have fast tests. We could imagine adding tests in the ChoiceTypeTest using a ChoiceLoader too, matching all existing tests for other ways to specify arguments, but I'm not sure it is worth it.

Commits
-------

5df64dc Fix the retrieval of the value with property path when using a loader
@stof stof deleted the fix_property_access_decorator branch August 27, 2015 10:27
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.

3 participants
0