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

[FrameworkBundle][Workflow] better errors when security deps are missing #23638

Merged
merged 1 commit into from
Aug 4, 2017

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jul 24, 2017

Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #23499 (comment)
License MIT
Doc PR

All the referenced services must either be explicitly configured or the SecurityBundle must be installed with some security related config being enabled. Otherwise, you will end up with a not so useful error message.

@xabbuh xabbuh added this to the 3.3 milestone Jul 24, 2017
@xabbuh xabbuh changed the title better errors when security deps are missing [FrameworkBundle][Workflow] better errors when security deps are missing Jul 24, 2017
/**
* @author Christian Flothmann <christian.flothmann@sensiolabs.de>
*/
class GuardListenerPass implements CompilerPassInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should probably contain Workflow as this is really just the for workflow configuration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to WorkflowGuardListenerPass

@xabbuh xabbuh force-pushed the guard-listener-security-deps branch from 9bb2c28 to f54c374 Compare July 24, 2017 07:42

public function testListenersAreNotRemovedIfAllDependenciesArePresent()
{
$this->container->setParameter('workflow.guard_listeners', ['foo.listener.guard', 'bar.listener.guard']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use long array syntax

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@xabbuh xabbuh force-pushed the guard-listener-security-deps branch from f54c374 to 8ec0db2 Compare July 25, 2017 13:09
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasParameter('workflow.guard_listeners')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the place setting this parameter in FrameworkBundle. Are you sure your code works fine ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed

@xabbuh xabbuh force-pushed the guard-listener-security-deps branch from 8ec0db2 to 3b884b0 Compare August 1, 2017 13:49
Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 except one little change.

return;
}

if (!$container->has('security.token_storage')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the parameter workflow.has_guard_listeners? It's not need at runtime.
(I added the comment here because I guess you will do it a this line ;) )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed :)

* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's need but now we add all Compiler pass in the associated component.
It's a forgetfulness or it's done on purpose? (I dont this it's necessary here but ...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is completely specifc to the FrameworkBundle. If you want to register the listener in the container in your own application, you will probably have better ways to check if all needed dependencies are present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@xabbuh xabbuh force-pushed the guard-listener-security-deps branch from 3b884b0 to 56ee4aa Compare August 4, 2017 07:27
@lyrixx
Copy link
Member

lyrixx commented Aug 4, 2017

👍

@lyrixx
Copy link
Member

lyrixx commented Aug 4, 2017

Thank you @xabbuh.

@lyrixx lyrixx merged commit 56ee4aa into symfony:3.3 Aug 4, 2017
lyrixx added a commit that referenced this pull request Aug 4, 2017
…ps are missing (xabbuh)

This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle][Workflow] better errors when security deps are missing

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23499 (comment)
| License       | MIT
| Doc PR        |

All the referenced services must either be explicitly configured or the SecurityBundle must be installed with some security related config being enabled. Otherwise, you will end up with a not so useful error message.

Commits
-------

56ee4aa better errors when security deps are missing
@xabbuh xabbuh deleted the guard-listener-security-deps branch August 4, 2017 08:11
@fabpot fabpot mentioned this pull request Aug 28, 2017
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

6 participants