-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Skip deep reference check for 'service_container' #18893
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
[DependencyInjection] Skip deep reference check for 'service_container' #18893
Conversation
30638f0
to
d8e4a94
Compare
Fixed the PHP 5.3 compatibility issue. PHP 7 failure seems to be unrelated. |
👍 |
public function __construct() | ||
{ | ||
$this->services = | ||
$this->scopedServices = |
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 would prefer to ini
8000
tialise both properties explicitly with array()
instead of using multi-line initialisations.
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.
This file is used to compare the generated/dumped container to. So this isn't code I actually wrote/would write, just the expected result of the container dump (which did fail without my fix).
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.
Sure, you are right. Sorry for the confusion.
👍 |
@@ -226,4 +226,14 @@ public function testCircularReference() | |||
$dumper = new PhpDumper($container); | |||
$dumper->dump(); | |||
} | |||
|
|||
public function testInlinedDefinitionReferencingServiceContainer() { |
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.
{
should be on its own line.
👍 |
Deep checks on whether a service references another service need to exclude the 'service_container' service as it doesn't exist. Without this dumping the container will fail if a service definition references an inlined service which has a direct or indirect dependency to the service_container.
d8e4a94
to
6f36733
Compare
Thank you @RobertMe. |
…ce_container' (RobertMe) This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] Skip deep reference check for 'service_container' | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | The "hasReference" check when dumping the container fails in the case where a service has a method call which includes a reference to a private/inlined service when either that service, or a dependency of it, references the service_container. This because service_container isn't defined while it still tries to check the references of it. So the service_container must be skipped in this case, this shouldn't break anything as the service_container doesn't reference any services, and thus can't reference the service which it is checking for. Commits ------- 6f36733 [DependencyInjection] Skip deep reference check for 'service_container'
Sorry to come back to this issue, but I think it was (accidentally) not merged upwards to 2.7, 2.8 et cetera. This because it was merged after the 3.1 release but just before the final 2.3.42 release. Afterwards there have been merges from 2.7, to 2.8, to 3.0 to 3.1, but I don't think these contained this fix already. |
@RobertMe Thanks for the heads up. This is now merged into the |
The "hasReference" check when dumping the container fails in the case where a service has a method call which includes a reference to a private/inlined service when either that service, or a dependency of it, references the service_container. This because service_container isn't defined while it still tries to check the references of it. So the service_container must be skipped in this case, this shouldn't break anything as the service_container doesn't reference any services, and thus can't reference the service which it is checking for.