Problem/Motivation

Drupal's Dependency Injection container is based on the Symfony project's DI component, with the biggest difference being that Drupal's compiled DI container is serialized to the database and not dumped to disk.

In addition, there are:

  1. features added to the upstream project and not yet implemented in Drupal or
  2. features overridden or suppressed in Drupal which may be eligible to be harmonized with upstream.

This is a meta issue for the broad goal of reducing differences from upstream, and allowing developers to be referred to the Symfony DI docs by default.

Proposed resolution

Add child issues to improve compatibility

Remaining tasks

fix all child issues

User interface changes

no

API changes

To be announced

Data model changes

no

Release notes snippet

no

Comments

bradjones1 created an issue. See original summary.

andypost’s picture

Version: 9.3.x-dev » 9.4.x-dev

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

neclimdul’s picture

Hope this is the right issue to surface this. This week I learned Drupal's containers have not mutation protections meaning services can end up with different versions of injected services. Kinda scary.

This led to a lot of reviewing ContainerBuilder::set

  1. re-enabling compiled mutation protections is probably straightforward and I opened an issue here: #3300306: Drupal ContainerBuilder allows mutation of non-synthetic services.
  2. #2531564: Fix leaky and brittle container serialization solution should be pruning the _serviceId oddness.
  3. The remaining logic in ContainerBuilder::set is forcing lowercase ids was added because of problems with old insensitive service IDs which don't exist anymore so we can probably remove that as well. Not 100% but removing this might be required for future autowiring cases where during build you want to set future services that are only the class and no alias.
    #2498293: Only allow lowercase service and parameter names
    https://symfony.com/blog/new-in-symfony-3-3-dependency-injection-depreca...

Mentioned it in the CB:set issue but similarly our Container::set contains none of the logic from Symfony's Container::set which mean it _also_ doesn't have any its mutation protections. Means you can modify containers mid request to dangerous effect. Since it doesn't inherit from Symfony's container that might be a much bigger lift and I haven't opened anything yet.

andypost’s picture

Priority: Normal » Major

it smells like major bug (#4)

louis-cuny’s picture

Indeed, this other issue will depend on this one.
https://www.drupal.org/project/drupal/issues/2218651

I already tryed to explain an issue with values that are kept from one request to another:
https://www.drupal.org/project/drupal/issues/3215035

andypost’s picture

andypost’s picture

andypost’s picture

Wim Leers’s picture

It's not clear from this meta's issue summary what remains to be done? 😅 Maybe everything's done? 🤞

andypost’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

There's a set of child issues and this plan is more like tracker for changes

Updated IS a bit to point it

longwave’s picture

Is this just a duplicate of #3021900: Bring new features from Symfony 3/4/5/6 into our container though? Should that become a parent meta?

andypost’s picture

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kim.pepper’s picture

vacho’s picture

Issue summary: View changes