Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[SecurityBundle] Move cache of the firewall context into the request parameters#22943
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| { | ||
| if ($this->contexts->contains($request)) { | ||
| return$this->contexts[$request]; | ||
| if ($request->attributes->has('_firewall_context')) { |
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.
you should validate that$request->attributes->get('_firewall_context') is a valid key of$this->map
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.
Done. And added test assertions on the value of this attribute.
stof commentedMay 29, 2017
why is it opened against the master branch if you want it for 3.4 ? master is 4.0 |
| return$this->contexts[$request]; | ||
| if ($request->attributes->has('_firewall_context')) { | ||
| $contextId =$request->attributes->get('_firewall_context'); | ||
| if (array_key_exists($contextId,$this->map)) { |
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.
$this->map can beTraversable (andit is)
chalasr left a comment
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.
Build failures unrelated
GromNaN commentedJun 5, 2017
Is it possible that a sub-request get created with all the attributes of its master request? In that case, using the request attributes as a cache would be wrong. |
fabpot left a comment
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.
Why does it target 3.4. Looks like a bug fix to me, so it should be done in earliest branches as well.
| } | ||
| /** | ||
| * @param Request $request |
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.
should be removed
| /** | ||
| * @param Request $request | ||
| * | ||
| * @return \Symfony\Bundle\SecurityBundle\Security\FirewallContext |
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.
You should add ause statement and useFirewallContext here instead.
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.
After this change, fabbot reports is as an unused import and removes theuse statement.
f335537 toe306ec0CompareGromNaN commentedJun 9, 2017
@fabpot The cache was introduced in 3.2. I've updated the PR. |
| namespaceSymfony\Bundle\SecurityBundle\Security; | ||
| usePsr\Container\ContainerInterface; | ||
| useSymfony\Bundle\SecurityBundle\Security\FirewallContext |
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.
missing; at then end
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.
Sorry, fixed.
Validate that _firewall_context attribute is in the map keys
fabpot commentedJun 10, 2017
Tests are broken. |
| $firewallContext =$this->getMockBuilder(FirewallContext::class)->disableOriginalConstructor()->getMock(); | ||
| $firewallContext->expects($this->once())->method('getConfig')->willReturn('CONFIG'); | ||
| $firewallContext->expects($this->once())->method('getContext')->willReturn(array('LISTENERS','EXCEPTION LISTENER')); |
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.
After merging into 3.3,getContext is replaced bygetListeners andgetExceptionListener, update this line to:
$firewallContext->expects($this->once())->method('getListeners')->willReturn('LISTENERS');$firewallContext->expects($this->once())->method('getExceptionListener')->willReturn('EXCEPTION LISTENER');
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.
Done, thanks
fabpot commentedJun 14, 2017
Thank you@GromNaN. |
…he request parameters (GromNaN)This PR was squashed before being merged into the 3.2 branch (closes#22943).Discussion----------[SecurityBundle] Move cache of the firewall context into the request parametersFollowing [this proposal](#22605 (comment)). Since the matching context relates to the request, this information should have been cached inside the request parameters.| Q | A| ------------- | ---| Branch? | 3.2| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#22605| License | MIT| Doc PR | n/a* Avoid memory leak when handling multiple requests* Adding the new request parameter `_firewall_context` might be considered as a breaking change. That adds a new "public" property that could be used by end developers.Commits-------b3203cb [SecurityBundle] Move cache of the firewall context into the request parameters
chalasr commentedJun 14, 2017
should be closed |
…ncyweb)This PR was merged into the 3.4 branch.Discussion----------[SecurityBundle][FirewallMap] Remove unused property| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets | no| License | MIT| Doc PR | -This property is unused. It was removed in#22943. It was likely reintroduced in a merge commit. It is still on master.Commits-------0904e57 [SecurityBundle][FirewallMap] Remove unused property
Uh oh!
There was an error while loading.Please reload this page.
Followingthis proposal. Since the matching context relates to the request, this information should have been cached inside the request parameters.
_firewall_contextmight be considered as a breaking change. That adds a new "public" property that could be used by end developers.