-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Do not load property_access.xml if the component isn't installed #24605
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
ogizanagi
wants to merge
2
commits into
symfony:2.7
from
ogizanagi:fix/2.7/serializer/object_normalizer_ex
Closed
[FrameworkBundle] Do not load property_access.xml if the component isn't installed #24605
ogizanagi
wants to merge
2
commits into
symfony:2.7
from
ogizanagi:fix/2.7/serializer/object_normalizer_ex
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added commit for option 2. |
My preference goes for option 2 as well. |
option 2 |
nicolas-grekas
approved these changes
Oct 28, 2017
fabpot
approved these changes
Oct 28, 2017
Thank you @ogizanagi. |
fabpot
added a commit
that referenced
this pull request
Oct 28, 2017
…omponent isn't installed (ogizanagi) This PR was squashed before being merged into the 2.7 branch (closes #24605). Discussion ---------- [FrameworkBundle] Do not load property_access.xml if the component isn't installed | Q | A | ------------- | --- | Branch? | 2.7 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #24563 (comment) <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A This PR actually aims to fix #24563 (comment) as the exception introduced in the PR can't be reached anyway when using the FrameworkBundle without the property access component as you'll get: > Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "PropertyAccessor" from namespace "Symfony\Component\PropertyAccess". With this fix, you properly get: > The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it. Not sure this change really belongs to a patch release, but the original PR was accepted in the 2.7 branch. Also, I'd rather remove the ObjectNormalizer definition if the component isn't available, as suggested by @xabbuh (#24563 (comment)). But in 2.7, this is the only normalizer registered by default and the [`SerializerPass` throws an exception if no normalizer is registered.](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SerializerPass.php#L46) To sum up, either: 1. we completly prevent using the FrameworkBundle and the serializer without the property access component, even if you don't really care about the ObjectNormalizer because you only use your owns specific ones. (and you'll get the exception hinting to install the property access component) 2. we allow using the FrameworkBundle and the serializer without the property access component, so we remove the ObjectNormalizer definition, but the user'll get a `You must tag at least one service as "serializer.normalizer" to use the Serializer service` exception until he configures a normalizer (and we don't get the hint about installing the property access component to enable the ObjectNormalizer. We already have a suggest entry in the composer.json file, though). To me option 2 looks better. WDYT? Commits ------- d297e27 [FrameworkBundle] Do not load property_access.xml if the component isn't installed
This was referenced Oct 30, 2017
Merged
Merged
This was referenced Nov 10, 2017
Merged
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR actually aims to fix #24563 (comment) as the exception introduced in the PR can't be reached anyway when using the FrameworkBundle without the property access component as you'll get:
With this fix, you properly get:
Not sure this change really belongs to a patch release, but the original PR was accepted in the 2.7 branch.
Also, I'd rather remove the ObjectNormalizer definition if the component isn't available, as suggested by @xabbuh (#24563 (comment)). But in 2.7, this is the only normalizer registered by default and the
SerializerPass
throws an exception if no normalizer is registered.To sum up, either:
You must tag at least one service as "serializer.normalizer" to use the Serializer service
exception until he configures a normalizer (and we don't get the hint about installing the property access component to enable the ObjectNormalizer. We already have a suggest entry in the composer.json file, though).To me option 2 looks better. WDYT?