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

[Validator] Number instances of validator service that has prototype scope is always 1 #13797

Closed
tienvx opened this issue Feb 26, 2015 · 3 comments

Comments

@tienvx
Copy link
Contributor

tienvx commented Feb 26, 2015

Problem: The validator service that has prototype scope is not created multiple times. So the number of instances is always 1.

How to reproduce:

  • Clone the bundle from GitHub
  • Enable the bundle, clear cache, etc.
  • Go to /app_dev.php/validate-authors
  • Check the result:
    • Expected: Number of instances is 10
    • Actually: Number of instances is 1

You can also run this command to test

phpunit -c app src/Tienvx/ReproduceBundle/

I followed this instruction to create a validator service.
I followed this document to make the service of prototype scope.
Here is the line I think that cause the problem.

Sorry for my English! This is the first time I rise a bug for Symfony.

@jakzal
Copy link
Contributor

jakzal commented Mar 4, 2015

I don't consider this as a bug. The service is requested from the container only once, and only a single instance is created.

Why would this be an issue? What are you trying to achieve?

@stof
Copy link
Member

stof commented Apr 4, 2015

The fact that the validator is loading constraint validators lazily indeed does not mean it loads them everytime to support scoped dependencies. This would either decrease performance for the common or would be a pain to manage.
If the loading was not lazy, the container would throw an exception when injecting the prototype-scoped service btw.

@webmozart
Copy link
Contributor

Closing due to lack of feedback.

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

4 participants