8000 [DependencyInjection] Skip deep reference check for 'service_container' by RobertMe · Pull Request #18893 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 1 commit into from
May 30, 2016

Conversation

RobertMe
Copy link
Contributor
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.

@RobertMe RobertMe force-pushed the reference-service-container branch 2 times, most recently from 30638f0 to d8e4a94 Compare May 27, 2016 06:10
@RobertMe
Copy link
Contributor Author

Fixed the PHP 5.3 compatibility issue. PHP 7 failure seems to be unrelated.

@nicolas-grekas
Copy link
Member

👍

public function __construct()
{
$this->services =
$this->scopedServices =
Copy link
Member

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.

Copy link
Contributor Author

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).

Copy link
Member

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.

@xabbuh
Copy link
Member
xabbuh commented May 29, 2016

👍

@@ -226,4 +226,14 @@ public function testCircularReference()
$dumper = new PhpDumper($container);
$dumper->dump();
}

public function testInlinedDefinitionReferencingServiceContainer() {
Copy link
Member

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.

@fabpot
Copy link
Member
fabpot commented May 29, 2016

👍

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.
@RobertMe RobertMe force-pushed the reference-service-container branch from d8e4a94 to 6f36733 Compare May 30, 2016 08:20
@nicolas-grekas
Copy link
Member

Thank you @RobertMe.

@nicolas-grekas nicolas-grekas merged commit 6f36733 into symfony:2.3 May 30, 2016
nicolas-grekas added a commit that referenced this pull request May 30, 2016
…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'
@fabpot fabpot mentioned this pull request May 30, 2016
@RobertMe
Copy link
Contributor Author
RobertMe commented Jun 5, 2016

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.

@xabbuh
Copy link
Member
xabbuh commented Jun 6, 2016

@RobertMe Thanks for the heads up. This is now merged into the 2.7 branch: https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L1271

This was referenced Jun 6, 2016
@fabpot fabpot mentioned this pull request Jun 15, 2016
@RobertMe RobertMe deleted the reference-service-container branch November 3, 2022 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0