diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index a132ff1..dfd2573 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -2,6 +2,7 @@ namespace Drupal\Core; +use Composer\Autoload\ClassLoader; use Drupal\Component\Assertion\Handle; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\Utility\Unicode; @@ -768,6 +769,20 @@ public function updateModules(array $module_list, array $module_filenames = arra // container in order to refresh the serviceProvider list and container. $this->containerNeedsRebuild = TRUE; if ($this->booted) { + // Rebuild the classloader by resetting the static inside the loader. We + // use reflection because \ComposerAutoloaderInitDrupal8 is a singleton + // and any other way of re-initializing the classloader requires + // hard-coding the vendor directory. It would also be possible to + // register additional class loaders to handle the new namespaces but this + // will cause problems for plugin discovery which relies upon the + // classloader attached to the container. + $reflected_loader = new \ReflectionClass(\ComposerAutoloaderInitDrupal8::class); + $reflected_static = $reflected_loader->getProperty('loader'); + $reflected_static->setAccessible(TRUE); + $reflected_static->setValue(NULL); + $this->classLoader->unregister(); + $this->classLoader = require $this->root . '/autoload.php'; + $this->initializeContainer(); } } diff --git a/core/modules/content_translation/src/ContentTranslationUpdatesManager.php b/core/modules/content_translation/src/ContentTranslationUpdatesManager.php index 6065c18..4fa54f3 100644 --- a/core/modules/content_translation/src/ContentTranslationUpdatesManager.php +++ b/core/modules/content_translation/src/ContentTranslationUpdatesManager.php @@ -95,7 +95,7 @@ public function onMigrateImport(MigrateImportEvent $event) { */ public static function getSubscribedEvents() { $events[ConfigEvents::IMPORT][] = ['onConfigImporterImport', 60]; - if (\Drupal::moduleHandler()->moduleExists('migrate')) { + if (class_exists('\Drupal\migrate\Event\MigrateEvents')) { $events[MigrateEvents::POST_IMPORT][] = ['onMigrateImport']; } return $events;