You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #48591 [DependencyInjection] Shared private services becomes public after a public service is accessed (alexpott)
This PR was merged into the 5.4 branch.
Discussion
----------
[DependencyInjection] Shared private services becomes public after a public service is accessed
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License | MIT
| Doc PR | N/a <!-- required for new features -->
<!--
If a private service is an argument to at least two other services and one of those services is public. If the public service is accessed via container::get() then the private service becomes available via container::get() afterwards.
Commits
-------
8437494 [DependencyInjection] Shared private services becomes public after a public service is accessed
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ReverseContainer.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -63,10 +63,6 @@ public function getId(object $service): ?string
63
63
*/
64
64
publicfunctiongetService(string$id): object
65
65
{
66
-
if ($this->serviceContainer->has($id)) {
67
-
return$this->serviceContainer->get($id);
68
-
}
69
-
70
66
if ($this->reversibleLocator->has($id)) {
71
67
return$this->reversibleLocator->get($id);
72
68
}
@@ -75,7 +71,6 @@ public function getService(string $id): object
75
71
thrownewServiceNotFoundException($id, null, null, [], sprintf('The "%s" service is private and cannot be accessed by reference. You should either make it public, or tag it as "%s".', $id, $this->tagName));
0 commit comments