Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Fixed some issues of the AccessDecisionManager profiler#18934
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
| $loader->load('guard.xml'); | ||
| if ($container->hasParameter('kernel.debug') &&$container->getParameter('kernel.debug')) { | ||
| if ($container->has('profiler')) { |
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 is broken, as it will always be false here (DI extensions are isolated from each other). You may need to use a compiler pass instead
javiereguiluzJun 2, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 looks overkill to me. Isn't there any other solution? In other extensions, for example inthese lines ofFrameworkExtension, they use the same code as here:
if ($container->getParameter('kernel.debug')) {$loader->load('templating_debug.xml');// ...}
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.
The big difference is that parameters are copied to the local container passed toExtension#load(), whereas services aren't.
And btw, this can only be done withkernel.* parameters, as these are set by the Kernel. All other parameters will only be available based on the order of the registered bundles in AppKernel: You don't want to depend on the order.
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.
@wouterj I don't understand your comment. In any case, I asked why this is wrong:
if ($container->getParameter('kernel.debug')) {$loader->load('security_debug.xml');}
When this is considered right:
if ($container->getParameter('kernel.debug')) {$loader->load('templating_debug.xml');// ...}
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.
It's about this:
if ($container->has('profiler')) {// ...}
Versus this:
if ($container->getParameter('kernel.debug')) {// ...}
The$container parameter ofExtension::load() isnot the actual container, it's a copy. Seehttps://github.com/symfony/dependency-injection/blob/master/Compiler/MergeExtensionConfigurationPass.php#L47-L49 Only the parameters are copied from actual to tmp container, services aren't.
This is why$container->has('profiler') willalways return false.
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.
Sure. I didn't use$container->has('profiler') at first. I used$container->getParameter('kernel.debug') but I was told that it was not completely right. But I still don't understand, so I can't fix it.
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.
@javiereguiluz the issue is that kernel.debug is only the default value for enabling the profiler. It is possible to enable it in non-debug mode.
And this mismatch is precisely one of the issues you have to fix, as the profiler always assumes that the debug access decision manager is there.
The alternative would be to handle properly the absence of this service (storing less info in the profiler panel)
| if ($container->hasParameter('kernel.debug') &&$container->getParameter('kernel.debug')) { | ||
| if ($container->getParameter('kernel.debug')) { | ||
| $loader->load('security_debug.xml'); |
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.
@javiereguiluz I tried this PR and the issue still exists :(
https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/Resources/config/collectors.xml#L13: Thedata_collector.security service ("which is always loaded" L66) requiredebug.security.access.decision_manager, so when$container->getParameter('kernel.debug') isfalse this service isn't loaded:
php bin/console --env=dev --no-debug [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] The service"profiler" has a dependency on a non-existent service"debug.security.access.decision_manager".
The road should be herehttps://github.com/symfony/symfony-standard/issues/968#issuecomment-223022665:
@stof: ... It should be based on whether the profiler is enabled instead of being based on the debug mode ...
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.
Is it OK to load thecollectors.xml file unconditionally? Is it really used whendebug = false ? If this can be changed, the solution would be trivial: move$loader->load('collectors.xml'); under theif ($container->getParameter('kernel.debug')) condition.
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.
well, if you do it, the security panel would not appear when enabling the profiler in no-debug mode, which might be confusing
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.
Could we checkweb_profiler.controller.profiler service definition ? it's defined only if WebProfileBundle is enabled. BUT, this would imply that all panels profile should be loaded only if this "WebProfileBundle" is enabled ? Currenly this is not taken into consideration in others collectors.
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.
@yceruto WebProfilerBundle is not related to enabling the profiler (the bundle does not provide the profiler. It is only about providing a visualization UI).
The proper service would be detectingprofiler (coming from FrameworkBundle), but this cannot be done in a DI extension, because DI extension cannot see services defined in other extensions (see the previous discussion)
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.
@stof you're right, then
... Only the parameters are copied from actual to tmp container ...
We can create a new parameter something likeprofiler.collect intoFrameworkExtension::registerProfilerConfiguration ?:
$container->setParameter('profiler.collect',$config['collect']);
and use it here ?
if ($container->hasParameter('profiler.collect') &&$container->getParameter('profiler.collect')) {$loader->load('collectors.xml');$loader->load('security_debug.xml');}
@javiereguiluz WDYT?
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.
fabpot commentedJun 16, 2016
@javiereguiluz Can you move this PR forward? Or do you need some help? |
peterrehm commentedJun 20, 2016
@javiereguiluz Any update on this? A solution would be awesome. |
javiereguiluz commentedJun 20, 2016
@peterrehm I plan to finish this very soon. |
javiereguiluz commentedJun 28, 2016
I've updated this with a compiler pass, as@stof suggested. |
| $loader->load('security_rememberme.xml'); | ||
| $loader->load('templating_php.xml'); | ||
| $loader->load('templating_twig.xml'); | ||
| $loader->load('collectors.xml'); |
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.
@javiereguiluz the issue still occurs ifprofiler service is not defined, sodata_collector.security require ofdebug.security.access.decision_manager
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.
Could we solve this via config?
<argumenttype="service"id="debug.security.access.decision_manager"on-invalid="ignore" />
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.
Or maybe just load the collector in debug?
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.
@HeahDude apparently we can't do that. See#18934 (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.
Ok, I see another solution, now that thesecurity.access.decision_manager is properly decorated, just pass it to the collector instead of thedebug.security.access.decision_manager,this line should ensure everything is fine, right?
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.
👍 Let's try that! Thanks.
javiereguiluz commentedJun 29, 2016
Some tests are still failing. Given that a new Symfony 3.1 release is imminent, could someone please help me fix this? Thanks! |
HeahDude commentedJun 29, 2016
If passing the |
e5dfabe toe4cbf01Compare| if ($container->hasParameter('kernel.debug') &&$container->getParameter('kernel.debug')) { | ||
| $loader->load('security_debug.xml'); | ||
| } | ||
| $loader->load('security_debug.xml'); |
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 did you remove the debug check?
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.
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.
Yes but now the check is done in the collector, so no need to load the debug adm when not in debug mode.
| $loader->load('guard.xml'); | ||
| if ($container->hasParameter('kernel.debug') &&$container->getParameter('kernel.debug')) { | ||
| if ($container->getParameter('kernel.debug')) { |
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 keep the check withhasParameter() since some tests are still failing
HeahDude commentedJun 29, 2016
I guess you now need to update the |
HeahDude commentedJun 29, 2016
👍 LGTM now, remaining failures are unrelated. Status: Reviewed |
| <argumenttype="service"id="security.role_hierarchy" /> | ||
| <argumenttype="service"id="security.logout_url_generator" /> | ||
| <argumenttype="service"id="debug.security.access.decision_manager" /> | ||
| <argumenttype="service"id="security.access.decision_manager" /> |
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.
if the compiler pass was removed then when this argument is changed bydebug.security.access.decision_manager ?
I missing something ?
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.
@yceruto the service is decorated when debug is on by loadingsecurity_debug.xml.
fabpot commentedJun 29, 2016
Thank you@javiereguiluz. |
…aviereguiluz)This PR was squashed before being merged into the 3.1 branch (closes#18934).Discussion----------Fixed some issues of the AccessDecisionManager profiler| Q | A| ------------- | ---| Branch? | 3.1| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#19022https://github.com/symfony/symfony-standard/issues/968schmittjoh/JMSSecurityExtraBundle#207| License | MIT| Doc PR | -Commits-------082f1b5 Fixed some issues of the AccessDecisionManager profiler
ioleo commentedJun 30, 2016
It's in the 3.1.x-dev branch, but not in the 3.1.1 tag :(@fabpot could you tag another patch release? |
peterrehm commentedJun 30, 2016
@loostro I think you need to be a bit patient, as@javiereguiluz wrote a new release is around the corner... |
Uh oh!
There was an error while loading.Please reload this page.