diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 5374bd3c75b3a26a1dcb560b52a0c00ca7455c48..10fabd412aaa3737b1d22a4ff4f523f9c6a8ca20 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -194,17 +194,6 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // Update the kernel to include it. $this->updateKernel($module_filenames); - // Replace the route provider service with a version that will rebuild - // if routes used during installation. This ensures that a module's - // routes are available during installation. This has to occur before - // any services that depend on the it are instantiated otherwise those - // services will have the old route provider injected. Note that, since - // the container is rebuilt by updating the kernel, the route provider - // service is the regular one even though we are in a loop and might - // have replaced it before. - \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]); @@ -294,6 +283,10 @@ 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'); diff --git a/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.info.yml b/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.info.yml deleted file mode 100644 index e7e55e5038ed58e9dce7749079f49cfccc2bdf97..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: 'Lazy route provider install test' -description: 'Helps test a bug triggered by the url_generator maintaining a stale route provider.' -type: module -package: Testing -version: VERSION -core: 8.x diff --git a/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.services.yml b/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.services.yml deleted file mode 100644 index 2de99d39e124c125f9be2da4457e3229527daf97..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.services.yml +++ /dev/null @@ -1,5 +0,0 @@ -services: - plugin.manager.lazy_route_provider_install_test: - class: '\Drupal\lazy_route_provider_install_test\PluginManager' - parent: default_plugin_manager - arguments: ['@url_generator'] diff --git a/core/modules/system/tests/modules/lazy_route_provider_install_test/src/PluginManager.php b/core/modules/system/tests/modules/lazy_route_provider_install_test/src/PluginManager.php deleted file mode 100644 index cac59a7324ff42f92808736ef4ce41aa7cdc8763..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/lazy_route_provider_install_test/src/PluginManager.php +++ /dev/null @@ -1,39 +0,0 @@ -set(__CLASS__, Url::fromRoute('system.admin')->toString()); - parent::__construct('Plugin/LazyRouteProviderInstallTest', $namespaces, $module_handler, NULL, PluginID::class); - } - -} diff --git a/core/modules/system/tests/modules/router_test_directory/router_test.install b/core/modules/system/tests/modules/router_test_directory/router_test.install deleted file mode 100644 index 7c718fa131bfb1690df55e299abb880cfd2c4932..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/router_test_directory/router_test.install +++ /dev/null @@ -1,17 +0,0 @@ -set(__FUNCTION__, Url::fromRoute('router_test.1')->toString()); -} diff --git a/core/tests/Drupal/FunctionalTests/Routing/LazyRouteProviderInstallTest.php b/core/tests/Drupal/FunctionalTests/Routing/LazyRouteProviderInstallTest.php deleted file mode 100644 index bc01dc288a51fbf78dbbb3d64db8b02d8c9c2660..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/FunctionalTests/Routing/LazyRouteProviderInstallTest.php +++ /dev/null @@ -1,28 +0,0 @@ -container->get('module_installer')->install(['router_test']); - // Note that on DrupalCI the test site is installed in a sub directory so - // we cannot use ::assertEquals(). - $this->assertStringEndsWith('/admin', \Drupal::state()->get('Drupal\lazy_route_provider_install_test\PluginManager')); - $this->assertStringEndsWith('/router_test/test1', \Drupal::state()->get('router_test_install')); - } - -}