Problem/Motivation
In #3392616-5: Update to Symfony 6.4 we've found out that the Symfony\Component\DependencyInjection\ContainerAwareTrait and Symfony\Component\DependencyInjection\ContainerAwareInterface are being deprecated in Symfony 6.4 and removed in 7.0.
Proposed resolution
We can't get rid off all implementations and will need to fork those into core (#3392616-8: Update to Symfony 6.4 and #3392616-20: Update to Symfony 6.4)
However, we want to get rid of as many usage as possible, for that there is #3397519: [META] Reduce use of ContainerAware classes where possible.
MR!5181 is the actual MR, but since that also removes all the deprecation suppression it currently fails (hard...).
However if we put the MRs of the children of #3397519: [META] Reduce use of ContainerAware classes where possible on top of that MR, as done in MR!5182, we are fully green.
Remaining tasks
Postponed on #3397173: Convert both BookNavigationCacheContext and MenuActiveTrailsCacheContext to use lazy services
Review
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3397522
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
spokjeNot quite sure what to do, the actual status would be PP-2, since this is waiting on the commit of both children of #3397519: [META] Reduce use of ContainerAware classes where possible to get rid of all the deprecation warnings.
But maybe someone wants to review the current state, so leave it on NW on my name for now.
Comment #5
quietone commentedAdding what this is postponed on to the remaining tasks per Remining tasks.
Changing parent to the S7 compatibility issue, so we find all the related issues.
Hmm. This looks like a situation where the new tag "Needs architectural review" can help. Adding tag and setting to NR.
Comment #6
longwaveThe event dispatcher just receives the entire container as an argument:
Can we just do this for the services that need it instead of copying the ContainerAware feature?
Comment #7
spokjeSince I have no clue what this means, I'm quickly un-assigning myself so somebody else can pick this up.
Comment #8
longwaveIt just means injecting the whole container as a service via a constructor argument, instead of using the ContainerAwareTrait/Interface helpers.
Comment #9
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #11
spokjeThis is the best I could do. I think I've changed all non-factory services to use the container in their constructor and deprecated all the (previously inherited)
setContainermethods.Comment #12
spokjeStarted working on some Factories, but I fear these will not work with constructors having a service container argument, since the container might not be ready yet?
It passes tests, but I would like some confirmation from somebody who actually knows what she/he is doing before continuing.
Comment #13
andypostAs I see in the MR5181 is the trait is removed but not replaced with fork, so summary needs update
Issue title said we gonna fork but MR doing replacement which is better to do as rector's rule to be reusable for contrib/custom code
IMO fixing just a namespace is preferable way, with follow-up to remove usage as the change very disruptive
Comment #14
smustgrave commentedBelieve #13 is enough for NW? If not feel free to put back.
Comment #15
claudiu.cristeaI've already hit this as in our project we're rejecting code triggering deprecations. It happened when some dependency updated Symfony from 6.3.5 to 6.4.1. Not sure whether to apply this patch or to pin Symfony
Comment #16
alexpottHere's a small patch to remove the deprecation from Symfony because you can't pin to 6.3.5 and use Drupal 10.2.1
Comment #17
alexpottComment #18
longwaveSo it looks like in many of these cases we should be using service locators instead of injecting the entire container:
CacheFactory, CacheTagsInvalidator, CheckProvider, StreamWrapperManager, KernelDestructionSubscriber all look like they could use this technique.
EntityTypeManager and ClassResolver are more tricky and need access to the entire container, but I think we could just inject the container as a service in these cases.
Comment #19
longwaveActually, KernelDestructionSubscriber can't use this because a service locator is a separate mini-container, and the destructor needs to know if each individual service was actually used in the main container.
Comment #20
longwaveOpened #3414625: Convert KernelDestructionSubscriber to use configurators for a slightly hacky way of dealing with KernelDestructionSubscriber.
Comment #21
longwaveOpened #3414627: Convert StreamWrapperManager to use a service locator to try out using a service locator in StreamWrapperManager.
Comment #22
longwave#3412556: Allow needs_destruction services to run on page cache hits removes KernelDestructionSubscriber entirely, so #3414625: Convert KernelDestructionSubscriber to use configurators can be closed if that lands.
Comment #23
longwaveOpened #3427741: Notify downstream users that ContainerAware is going away which would mean this can be closed as won't fix.
Comment #24
longwave#3427741: Notify downstream users that ContainerAware is going away landed and we should be able to remove ContainerAware support entirely from Drupal 11 in #3431362: Remove support for ContainerAwareInterface.