Extension System, Part IV: Properly register all installed extensions/namespaces during container generation

Created on 2 February 2018, over 6 years ago
Updated 29 February 2024, 4 months ago

Problem/Motivation

Not all installed extensions, and their respective namespaces, are properly registered within the container.

This issue is, primarily, relevant to themes and theme engines as modules and profiles are currently hardcoded.

Certain requests only bootstrap so far. If a theme provides a static callback (in the form of #pre_render, #ajax, or #lazy_builder) to a method in one of its classes, this lives in a render array which can become cached. Because of this caching, the entire theme system does not necessarily need to be loaded just to execute a callback. Thus, the namespaces are never registered and the classes cannot be found.

It is a common misnomer that extension namespaces are registered on install.

Currently, the ThemeExtensionList is what instantiates and registers all installed theme namespaces.

DrupalKernel::compileContainer automatically registers module namespaces, simply because they can provide services (since themes cannot). However, these namespaces are done after the service providers have been determined and effectively cut all other installed extension types out of being properly registered.

There are also no significant tests to ensure that these namespaces are registered properly and whether or not they would in fact break contrib.

Proposed resolution

Register all installed extensions and their namespaces as separate container parameters:

  • container.namespaces.core - Drupal specific ['Core', 'Component'] namespaces.
  • container.namespaces.module
  • container.namespaces.profile
  • container.namespaces.theme
  • container.namespaces.theme_engine
  • container.namespaces.all - all of the above namespaces

For BC reasons, the existing container.namespaces parameter/service needs to be aliased to the following namespaces:

  • container.namespaces.core
  • container.namespaces.module
  • container.namespaces.profile

And then deprecate the use of container.namespaces when #2954562: [PP-2] Create provider based plugin managers β†’ makes it way in to allow plugin managers to choose which namespaces to allow.

Remaining tasks

  • Create tests
  • Create a patch

User interface changes

None

API changes

Data model changes

None

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
ExtensionΒ  β†’

Last updated about 18 hours ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States markhalliwell

Live updates comments and jobs are added and updated live.
  • Needs framework manager review

    It is used to alert the framework manager core committer(s) that an issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy draft for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024