Skip to content

[DependencyInjection] Fix cloned lazy services not sharing their dependencies when dumped with PhpDumper #59723

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

Conversation

pvandommelen
Copy link
Contributor

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #59706
License MIT

Fixes referenced services not being shared when lazy services are cloned before being initialized. Adds tests for both the ghost and proxy scenario's.

This makes the inlining behaviour more conservative, which impacts the outputs of some other test cases.

First commit adds a test, second commit has the fix. Third commit also considers the proxy case, which is also affected. I can squash if necessary.

Targeted 6.4, but this also applies to 7.x.

@pvandommelen pvandommelen force-pushed the share_lazy_service_dependency branch 3 times, most recently from cba91d9 to 9ea5995 Compare February 7, 2025 14:25
@pvandommelen
Copy link
Contributor Author

Updated. I don't think the failing tests are related.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM thanks, just some CS tweaks needed.

@pvandommelen
Copy link
Contributor Author

Resolved style comments

@nicolas-grekas
Copy link
Member

Note that when using native proxies, cloning will trigger initialization.
You should not rely on the current behavior when cloning.

(The patch is still fixing a valid concern since we're not coupled to one implementation)

@nicolas-grekas nicolas-grekas force-pushed the share_lazy_service_dependency branch from c93c0d5 to a60cff5 Compare February 10, 2025 08:06
@nicolas-grekas
Copy link
Member

Thank you @pvandommelen.

@nicolas-grekas nicolas-grekas merged commit 0247b1b into symfony:6.4 Feb 10, 2025
8 of 9 checks passed
@pvandommelen pvandommelen deleted the share_lazy_service_dependency branch February 10, 2025 08:08
@pvandommelen
Copy link
Contributor Author

Thanks for the quick reviews!

This was referenced Feb 26, 2025
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.

5 participants