Skip to content

[FrameworkBundle] give access to non-shared services when using test.service_container #27528

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
Jun 15, 2018

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.1
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27488
License MIT
Doc PR -

@@ -32,6 +32,10 @@ public function process(ContainerBuilder $container)

foreach ($definitions as $id => $definition) {
if ($id && '.' !== $id[0] && (!$definition->isPublic() || $definition->isPrivate()) && !$definition->getErrors() && !$definition->isAbstract()) {
if (!$definition->isShared()) {
$definition->setShared(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this cause issues regarding inlining ? Rules are not the same for shared and not shared services.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will change the resulting inlining yes that's the goal, but inlining is only an optimization: it has no external side effect, so this is neutral, behavior wise.

@nicolas-grekas
Copy link
Member Author

Implementation updated, with logic added to the inlining pass: when a non-shared service is weak-referenced, it cannot be inlined.

@nicolas-grekas
Copy link
Member Author

(deps=high failure will be fixed when this is merged up to master.)

@nicolas-grekas nicolas-grekas merged commit 516ff5a into symfony:4.1 Jun 15, 2018
nicolas-grekas added a commit that referenced this pull request Jun 15, 2018
…using test.service_container (nicolas-grekas)

This PR was merged into the 4.1 branch.

Discussion
----------

[FrameworkBundle] give access to non-shared services when using test.service_container

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27488
| License       | MIT
| Doc PR        | -

Commits
-------

516ff5a [FrameworkBundle] give access to non-shared services when using test.service_container
@nicolas-grekas nicolas-grekas deleted the test-aliases branch June 15, 2018 10:41
@fabpot fabpot mentioned this pull request Jun 25, 2018
nicolas-grekas added a commit that referenced this pull request Nov 12, 2021
…s are involved (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] fix inlining when non-shared services are involved

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #43980
| License       | MIT
| Doc PR        | -

I'm unable to write a service graph that hits the bug, but this is still fixing the referenced issue appropriately.
As a reminder, since #27528, we don't inline non-shared service as soon as they're referenced by a service locator.
But when doing so, we need to ensure that the shared services referenced by such non-inlined-non-shared services are not themselves inlined, since that'd break the non-inlined-non-shared services.
This patch does it :)

Commits
-------

3ff048b [DependencyInjection] fix inlining when non-shared services are involved
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.

3 participants