Skip to content
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] Fix fetching lazy non-shared services multiple times #50985

Merged

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented Jul 14, 2023

Q A
Branch? 6.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #50975
License MIT
Doc PR -

An attempt to fix #50975.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 16, 2023

Thanks for having a look. I checked why the id could come as first argument and I think the fix we need is this one:

--- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
@@ -900,6 +900,8 @@ EOF;
 
                     if ($asFile) {
                         $code .= "fn () => self::do(\$container);\n\n";
+                    } elseif ($definition->isPublic()) {
+                        $code .= sprintf("fn() => \$this->%s();\n\n", $methodName);
                     } else {
                         $code .= sprintf("\$this->%s(...);\n\n", $methodName);
                     }

WDYT?

@HypeMC HypeMC force-pushed the fix-fetching-of-lazy-non-shared-services branch from f35d0f2 to ef2626f Compare July 16, 2023 16:48
@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit c2d9407 into symfony:6.2 Jul 16, 2023
7 of 9 checks passed
@HypeMC HypeMC deleted the fix-fetching-of-lazy-non-shared-services branch July 16, 2023 16:56
@HypeMC
Copy link
Contributor Author

HypeMC commented Jul 16, 2023

@nicolas-grekas There's one more case this doesn't cover, see #50996 .

nicolas-grekas added a commit that referenced this pull request Jul 19, 2023
…ces multiple times with as files `true` (HypeMC)

This PR was merged into the 6.3 branch.

Discussion
----------

[DependencyInjection] Fix fetching lazy non-shared services multiple times with as files `true`

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

Followup to #50985, fixes case when `as_files` is `true`.

This particular problem exists only on v6.3 and was introduced in #48469.

Commits
-------

cb434a4 [DependencyInjection] Fix fetching lazy non-shared services multiple times with as files true
This was referenced Jul 30, 2023
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.

None yet

3 participants