only in patch2: unchanged: --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -194,6 +194,10 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // Update the kernel to include it. $this->updateKernel($module_filenames); + // In order to make installing transactional if anything uses routes. + \Drupal::getContainer()->set('router.route_provider.old', \Drupal::service('router.route_provider')); + \Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.lazy_builder')); + // Allow modules to react prior to the installation of a module. $this->moduleHandler->invokeAll('module_preinstall', [$module]); @@ -283,10 +287,6 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // @see https://www.drupal.org/node/2208429 \Drupal::service('theme_handler')->refreshInfo(); - // In order to make uninstalling transactional if anything uses routes. - \Drupal::getContainer()->set('router.route_provider.old', \Drupal::service('router.route_provider')); - \Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.lazy_builder')); - // Allow the module to perform install tasks. $this->moduleHandler->invoke($module, 'install');