Skip to content

Deprecation in UserPasswordEncoderCommand::__construct is always throw when you test another command #22855

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
xkobal opened this issue May 22, 2017 · 6 comments

Comments

@xkobal
Copy link
Contributor

xkobal commented May 22, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3RC1

When you're using the Symfony way to test command (https://symfony.com/doc/current/console.html#testing-commands), you 'always got a deprecation when the command list is build, because the deprecation is in the __construct(), even if I never used this command in my tests.

Passing null as the first argument of "Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand::__construct" is deprecated since version 3.3 and will be removed in 4.0. If the command was registered by convention, make it a service instead

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone May 22, 2017
@ogizanagi
Copy link
Contributor

ogizanagi commented May 22, 2017

Could you provide a reproducer? I tried the test in symfony-demo but cannot reproduce (even by using the exact same code as in the mentioned documentation).

Anyway, it looks very weird to me, as this command is now registered as a service by the SecurityBundle and the dependency is always provided.
Have you extended the command in your project or registered it manually?

@xkobal
Copy link
Contributor Author

xkobal commented May 22, 2017

I will try to provide a reproducer tomorrow. You have to run tests with an empty cache.

The UserPasswordEncoderCommand is neither extended or registered in y projet.

@chalasr
Copy link
Member

chalasr commented May 22, 2017

See #22858

@xkobal
Copy link
Contributor Author

xkobal commented May 22, 2017

Thanks @chalasr , same problem I think.

@chalasr
Copy link
Member

chalasr commented May 22, 2017

@xkobal Would you mind to apply #22858 on your project and confirm it fixes the issue?

@xkobal
Copy link
Contributor Author

xkobal commented May 23, 2017

@chalasr it works with #22858 ! thanks

nicolas-grekas added a commit that referenced this issue May 23, 2017
…EncoderCommand (chalasr)

This PR was merged into the 3.3 branch.

Discussion
----------

[SecurityBundle] Prevent auto-registration of UserPasswordEncoderCommand

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22855
| License       | MIT
| Doc PR        | n/a

Always registers the command as a service even if no encoders are configured so that it is not auto-registered via reflection.
Prevents an irrelevant deprecation when no encoders are configured and, if a day the per-convention command registration is removed, ensures that the command always exists (leading to an exception saying that you have no configured encoder, better than nothing).
ping @ogizanagi

Commits
-------

b39b35b Prevent auto-registration of UserPasswordEncoderCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants