diff -u b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php --- b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -3,7 +3,6 @@ namespace Drupal\Core\Extension; use Drupal\Component\FileCache\FileCacheFactory; -use Drupal\Core\DependencyInjection\ContainerNotInitializedException; use Drupal\Core\DrupalKernel; use Drupal\Core\Extension\Discovery\RecursiveExtensionFilterIterator; use Drupal\Core\Site\Settings; @@ -123,11 +122,14 @@ // ExtensionDiscovery can be used without a service container // (@drupalKernel::moduleData), so create a fallback profile handler if the - // container is not initialized yet. - try { - $this->profileHandler = $profile_handler ?: \Drupal::service('profile_handler'); + // profile_handler service is unavailable. + if ($profile_handler) { + $this->profileHandler = $profile_handler; } - catch (ContainerNotInitializedException $e) { + elseif (\Drupal::hasService('profile_handler')) { + $this->profileHandler = \Drupal::service('profile_handler'); + } + else { $this->profileHandler = new FallbackProfileHandler($root); } }