Skip to content
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

[Form] Fix casting regression in DoctrineChoiceLoader #17006

Merged
merged 1 commit into from Dec 15, 2015
Merged

[Form] Fix casting regression in DoctrineChoiceLoader #17006

merged 1 commit into from Dec 15, 2015

Conversation

bendavies
Copy link
Contributor

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

In symfony 2.7, the DoctrineChoiceLoader and IdReader were introduce to replace the deprecated EntityChoiceList

There appears to have been a change in behaviour in the refactor, as the old EntityChoiceList casts ID to strings, whereas the new DoctrineChoiceLoader does not. The casting behavior was maintained elsewhere, however.

Since the new DoctrineChoiceLoader deprecated EntityChoiceList, i'm calling this a regression.

@Tobion
Copy link
Member

Tobion commented Dec 14, 2015

What does this fix? What type is the id value that you want to cast?

@bendavies
Copy link
Contributor Author

Well, does that even matter? It's a regression right?
But for info, https://github.com/ramsey/uuid-doctrine

@Tobion
Copy link
Member

Tobion commented Dec 14, 2015

Just because the new version doesn't behave exactly like the deprecated one doesn't mean it's a regression.

@Tobion
Copy link
Member

Tobion commented Dec 14, 2015

Btw, for your use-case the string case is not safe to use anyway, because the https://github.com/ramsey/uuid/blob/master/src/UuidInterface.php does not mandate a __toString method.

@bendavies
Copy link
Contributor Author

If you don't want to classify it as a regression, fine, although the feels like a stretch in this particular case.

My change is making the behaviour consistent throughout the class. It's casted to string in one place but not a other.

My particular use case has no relevance in the discussion.

@bendavies
Copy link
Contributor Author

Thoughts @webmozart? Since you wrote it.

@eXtreme
Copy link
Contributor

eXtreme commented Dec 14, 2015

Well it is used as a key in an array and ID in doctrine can be a value object.

@webmozart
Copy link
Contributor

I think it's fine to make this change. Could you add a test case though?

@bendavies
Copy link
Contributor Author

@webmozart thanks, will do

@bendavies
Copy link
Contributor Author

@webmozart how's that?

@webmozart
Copy link
Contributor

👍

@Tobion
Copy link
Member

Tobion commented Dec 15, 2015

Thank you @bendavies.

@Tobion Tobion merged commit 54bbade into symfony:2.7 Dec 15, 2015
Tobion added a commit that referenced this pull request Dec 15, 2015
…davies)

This PR was merged into the 2.7 branch.

Discussion
----------

[Form] Fix casting regression in DoctrineChoiceLoader

| 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

In symfony 2.7, the [DoctrineChoiceLoader](https://github.com/symfony/symfony/blob/9543b36a34221aaca9f2f3cfe34112e8468a591a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php) and [IdReader](https://github.com/symfony/symfony/blob/9543b36a34221aaca9f2f3cfe34112e8468a591a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php) were introduce to replace the deprecated [EntityChoiceList](https://github.com/symfony/symfony/blob/9543b36a34221aaca9f2f3cfe34112e8468a591a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php)

There appears to have been a change in behaviour in the refactor, as the old `EntityChoiceList` [casts ID to strings](https://github.com/symfony/symfony/blob/9543b36a34221aaca9f2f3cfe34112e8468a591a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php#L248), whereas the new `DoctrineChoiceLoader` [does not](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php#L159). The casting behavior was [maintained elsewhere](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php#L122), however.

Since the new `DoctrineChoiceLoader` deprecated `EntityChoiceList`, i'm calling this a regression.

Commits
-------

54bbade [Form] cast IDs to match deprecated behaviour of EntityChoiceList
@bendavies
Copy link
Contributor Author

Thanks @Tobion

This was referenced Dec 26, 2015
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.

None yet

5 participants