Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] deprecate access to private shared services.#19146
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
02e1480 to9af32f8Comparehhamon commentedJun 22, 2016
Looks like fabbot gives a false positive! |
fabpot commentedJun 23, 2016
But tests are truly broken :) |
| * Requesting a private shared service with the`get()` method of the`Container` | ||
| class is no longer supported and will raise an exception. | ||
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 also need to add a note in the component CHANGELOG file.
fabpot commentedJun 23, 2016
I would have implemented this feature in a different way by renaming internally private services so that their original name is not available from the container (this is what we are doing for anonymous services for instance). |
xabbuh commentedJun 23, 2016
I think it's a good idea to switch to generated ids in 4.0. For now I like this approach as it allows users to fix their applications more smoothly. |
| $id =$lcId; | ||
| }else { | ||
| if (isset($this->privates[$id])) { | ||
| @trigger_error(sprintf('Checking for the existence of the private service "%s" is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0. An exception will be thrown instead in Symfony 4.0.',$id),E_USER_DEPRECATED); |
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 throw an exception in this case? If you check a private service for existence, the method should returnfalse, 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.
Yes
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 it makes more sense!
fabpot commentedJun 23, 2016
@xabbuh Fair enough, let's keep the current approach for now. |
hhamon commentedJun 23, 2016
I'll update the code later today to reflect your comments. |
| } | ||
| if (isset($this->privates[$id])) { | ||
| @trigger_error(sprintf('Resetting the private service "%s" from outside of the container is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0. An exception will be thrown instead in Symfony 4.0.',$id),E_USER_DEPRECATED); |
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.
. and is part of new sentence part and should start with an uppercase 👍
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.
Where is that?
stof commentedJun 23, 2016
@fabpot generated ids are a good idea for 4.0 indeed, but this cannot be done for deprecations. If we want to switch to generated ids already, we would have to build another feature to to store a mapping between shared private service ids and their generated ids, to retrieve them this way and trigger a deprecation, which would again look like this approach. |
18ba656 to19f3c66Comparehhamon commentedJun 23, 2016
I don't understand why the tests suite fails on PHP 5.5 and HHVM. The failing test in the ProxyManager Bridge passes on my machine with PHP 5.5.36... |
| return; | ||
| } | ||
| if (isset($this->privates[$id])) { | ||
| @trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0. An exception will be thrown instead in Symfony 4.0.',$id),E_USER_DEPRECATED); |
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.
I won't necessarily throw an exception as it depends on the$invalidBehavior value.
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 that's right!
GuilhemN commentedJun 24, 2016
The tests are missing for the |
hhamon commentedJun 24, 2016
Thanks @Ener-Getick! I'm going to add some ;) |
a43a537 to13edce2Comparehhamon commentedJun 27, 2016
I guess it's now ready for another round of reviews if tests pass. |
nicolas-grekas commentedJun 27, 2016
👍 (fabbot fails on a fixture, unrelated) |
UPGRADE-4.0.md Outdated
| no longer supported. Only public services can be set or unset. | ||
| * Checking the existence of a private service with the`Container::has()` | ||
| method is no longer supported. |
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 not that it is not supported anymore but more that it's going to return false.
fabpot commentedJun 28, 2016
Apart from my minor comment, 👍 |
hhamon commentedJun 28, 2016
@fabpot fixed! CI is running ;) |
hhamon commentedJun 28, 2016
Good to go! |
fabpot commentedJun 29, 2016
Thank you@hhamon. |
…ed services. (hhamon)This PR was merged into the 3.2-dev branch.Discussion----------[DependencyInjection] deprecate access to private shared services.| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | yes| Tests pass? | yes| Fixed tickets |#19117| License | MIT| Doc PR | ~Commits-------4ed70c4 [DependencyInjection] deprecate access to private shared services. Fixes issue#19117.
…rvices (ro0NL)This PR was merged into the 4.0-dev branch.Discussion----------[DI] Removed deprecated setting private/pre-defined services| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | yes| Deprecations? | no| Tests pass? | yes| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->See#21533,#19708 and#19146@nicolas-grekas privates should be excluded from `getServiceIds` right? i also wondered.. did we forget to deprecate checking privates with `initialized()`?Commits-------9f96952 [DI] Removed deprecated setting private/pre-defined services
Uh oh!
There was an error while loading.Please reload this page.