Issue #3616863: Decorate the library discovery service the running core builds library info with

domain_config decorates the library discovery cache collector to add the active domain to the library info cache id. Core moved that collector from library.discovery.collector to library.discovery in Drupal 11.1 and nothing has read library.discovery.collector since, so on Drupal 11.1 and later the decoration was never used and every domain shared one library_info:THEME entry.

DomainConfigServiceProvider::alter() now reads the container rather than the core version: when the class of the library.discovery definition is a LibraryDiscoveryCollector, the domain_config definition is pointed at it with setDecoratedService(). Decoration is resolved during compilation, after alter() runs, so the definition read there is still the one core registered. Up to Drupal 11.0 nothing changes: library.discovery is the LibraryDiscovery wrapper, and swapping the decoration there would break the Drupal\Core\Asset\LibraryDiscoveryInterface alias, since the collector does not implement that interface on those releases.

The service id and the collector class are untouched, so nothing external to the module changes.

New kernel coverage, DomainConfigLibraryDiscoveryTest: the test module ships a library whose version its hook_library_info_alter() implementation reads from configuration overridden per domain. The first domain builds the definitions and the collector writes them to the discovery cache, then the second domain must build its own rather than read that entry. It resolves the collector the same way the service provider picks it, so it exercises whichever service the running core uses.

Verified on both cores this branch supports:

core with the service provider without it
10.6.15 OK (2 tests, 11 assertions) OK, unchanged
11.3.16 OK 2 failures

DomainConfigOverrideEditableTest passes on both as well, phpcs with the CI standard is clean over the whole module, and phpstan reports no errors.

The same change applies to 3.0.x, which carries the same service definition and the same core requirement.

Merge request reports

Loading
Loading