-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBridge] Make AppVariable check if security.context exists #14816
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an exception saying it is not available (as done in the previous case) may make more sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I know, but it will make the check in templates unusable if third-party bundles relies on it to activate templates sections when the
security
is configured.GlobalVariables
class, previously used for twig app globals in previous versions did this very same check and returnednull
when the service didn't exist.So, this is basically a BC break. :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then we should indeed return null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm indeed wondering why we should throw a
RuntimeException
in the above case where the container isn't defined. When does this particular case might happen ? Does it make sense to throw this exception instead of returningnull
?Obviously, if this PR is merged as it is, we'll have some kind of inconsistency. It feels odd, and the same might be applicable to
request
andsession
globals...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about deprecating that behaviour with Symfony 2.8 and throw the exception starting with 3.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. It was an easy way to enable or hide sections in templates, depending on the application configuration without much effort. Apps will require to check themselves if security is configured and inject the result in every template where they need it, or create their own global.
When does returning
null
in such case became wrong ? I can't find anything mentioning the reasons in #13354