Skip to content

[Contracts] remove static cache from ServiceSubscriberTrait #46478

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 29, 2022

Conversation

kbond
Copy link
Member

@kbond kbond commented May 27, 2022

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

I found an edge case when using this trait on a class that extends a parent class that implements getSubscribedServices(). The issue occurs if the parent dynamically determines the return value of getSubscribedServices() based on something in the child class (in my case, using reflection). It's fine if only one class extends this parent but when multiple do, only the first class registered in the container has the proper services. The next classes have the same as the first because of the static variable.

@kbond kbond force-pushed the service-subscriber-static branch from 85957c7 to d0843be Compare May 27, 2022 14:01
@carsonbot carsonbot changed the title [DependencyInjection] remove static cache from ServiceSubscriberTrait [Contracts] remove static cache from ServiceSubscriberTrait May 29, 2022
@nicolas-grekas
Copy link
Member

Thank you @kbond.

@nicolas-grekas nicolas-grekas merged commit 61f38c7 into symfony:4.4 May 29, 2022
@kbond kbond deleted the service-subscriber-static branch June 7, 2022 16:38
@fabpot fabpot mentioned this pull request Jun 9, 2022
This was referenced Jun 26, 2022
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.

4 participants