Skip to content
Snippets Groups Projects
Commit 7d18acfe authored by catch's avatar catch
Browse files

Issue #2788087 by alexpott, dawehner, shafiqhossain: Drupal 8: You have...

Issue #2788087 by alexpott, dawehner, shafiqhossain: Drupal 8: You have requested a non-existent service "router.route_provider.old"
parent 7f68a3d4
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -309,7 +309,11 @@ public function install(array $module_list, $enable_dependencies = TRUE) { ...@@ -309,7 +309,11 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
// If any modules were newly installed, invoke hook_modules_installed(). // If any modules were newly installed, invoke hook_modules_installed().
if (!empty($modules_installed)) { if (!empty($modules_installed)) {
// If the container was rebuilt during hook_install() it might not have
// the 'router.route_provider.old' service.
if (\Drupal::hasService('router.route_provider.old')) {
\Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.old')); \Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.old'));
}
if (!\Drupal::service('router.route_provider.lazy_builder')->hasRebuilt()) { if (!\Drupal::service('router.route_provider.lazy_builder')->hasRebuilt()) {
// Rebuild routes after installing module. This is done here on top of // Rebuild routes after installing module. This is done here on top of
// \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on // \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on
......
...@@ -34,4 +34,9 @@ function module_test_install() { ...@@ -34,4 +34,9 @@ function module_test_install() {
'data' => $schema['fields']['data']['type'], 'data' => $schema['fields']['data']['type'],
]) ])
->execute(); ->execute();
if (\Drupal::state()->get('module_test_install:rebuild_container')) {
// Ensure that the container can be rebuilt during hook_install(). Doing
// this in hook_install() is bad practice but it should not break anything.
\Drupal::service('kernel')->rebuildContainer();
}
} }
...@@ -85,4 +85,13 @@ public function testCacheBinCleanup() { ...@@ -85,4 +85,13 @@ public function testCacheBinCleanup() {
$this->assertFalse($schema->tableExists($table)); $this->assertFalse($schema->tableExists($table));
} }
/**
* Ensure that rebuilding the container in hook_install() works.
*/
public function testKernelRebuildDuringHookInstall() {
\Drupal::state()->set('module_test_install:rebuild_container', TRUE);
$module_installer = $this->container->get('module_installer');
$this->assertTrue($module_installer->install(['module_test']));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment