Change record status: 
Project: 
Introduced in branch: 
11.5.x
Introduced in version: 
11.5.0
Description: 

LibraryDiscoveryCollector::__construct() gains a new \Psr\Log\LoggerInterface $logger argument. It is used to log a warning when library discovery is requested for an unknown extension — for example a client-supplied ajax_page_state[libraries] value referencing a module or theme that was uninstalled, or a tampered request — rather than letting the UnknownExtensionException surface or swallowing it silently.

What changed

public function __construct(
  CacheBackendInterface $cache,
  LockBackendInterface $lock,
  LibraryDiscoveryParser $discovery_parser,
  ThemeManagerInterface $theme_manager,
  LoggerInterface $logger,
);

The library.discovery service is wired to the existing logger.channel.default channel automatically, so container-based usage needs no changes. The argument is optional until it becomes required in drupal:13.0.0.

Who is affected

Only code that instantiates LibraryDiscoveryCollector directly, or decorates the library.discovery service with explicit arguments. Omitting $logger triggers:

Calling Drupal\Core\Asset\LibraryDiscoveryCollector::__construct() without the $logger argument is deprecated in drupal:11.5.0 and will be required in drupal:13.0.0. See https://www.drupal.org/node/3601471

Before

$collector = new LibraryDiscoveryCollector($cache, $lock, $discovery_parser, $theme_manager);

After

$collector = new LibraryDiscoveryCollector($cache, $lock, $discovery_parser, $theme_manager, \Drupal::service('logger.channel.default'));
Impacts: 
Module developers