diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 412a7b3..afba2ff 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -295,7 +295,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // If any modules were newly installed, invoke hook_modules_installed(). if (!empty($modules_installed)) { - \Drupal::service('router.builder')->rebuild(); + \Drupal::service('router.builder')->setRebuildNeeded(); $this->moduleHandler->invokeAll('modules_installed', array($modules_installed)); } @@ -437,7 +437,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { $schema_store = \Drupal::keyValue('system.schema'); $schema_store->delete($module); } - \Drupal::service('router.builder')->rebuild(); + \Drupal::service('router.builder')->setRebuildNeeded(); drupal_get_installed_schema_version(NULL, TRUE); // Let other modules react. diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index db516af..c3f494a 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -45,13 +45,6 @@ class RouteBuilder implements RouteBuilderInterface, DestructableInterface { protected $dispatcher; /** - * The yaml discovery used to find all the .routing.yml files. - * - * @var \Drupal\Component\Discovery\YamlDiscovery - */ - protected $yamlDiscovery; - - /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface @@ -232,10 +225,8 @@ public function destruct() { * The defined routes, keyed by provider. */ protected function getRouteDefinitions() { - if (!isset($this->yamlDiscovery)) { - $this->yamlDiscovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories()); - } - return $this->yamlDiscovery->findAll(); + $discovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories()); + return $discovery->findAll(); } } diff --git a/core/modules/book/src/Tests/BookUninstallTest.php b/core/modules/book/src/Tests/BookUninstallTest.php index dbd4de5..5762366 100644 --- a/core/modules/book/src/Tests/BookUninstallTest.php +++ b/core/modules/book/src/Tests/BookUninstallTest.php @@ -23,14 +23,13 @@ class BookUninstallTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'user', 'field', 'filter', 'text', 'entity_reference', 'node', 'book'); + public static $modules = array('user', 'field', 'filter', 'text', 'entity_reference', 'node', 'book'); /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installEntitySchema('user'); $this->installEntitySchema('node'); $this->installSchema('book', array('book')); diff --git a/core/modules/ckeditor/src/Tests/CKEditorTest.php b/core/modules/ckeditor/src/Tests/CKEditorTest.php index ab303b6..25558d3 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php @@ -44,7 +44,6 @@ protected function setUp() { // Install the Filter module. $this->installSchema('system', 'url_alias'); - $this->installSchema('system', 'router'); // Create text format, associate CKEditor. $filtered_html_format = entity_create('filter_format', array( diff --git a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php index ddfaf8f..3cb8ab0 100644 --- a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php +++ b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php @@ -29,7 +29,6 @@ class CommentStringIdEntitiesTest extends KernelTestBase { 'field_ui', 'entity', 'entity_test', - 'system', 'text', ); @@ -37,7 +36,6 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('comment'); $this->installSchema('comment', array('comment_entity_statistics')); - $this->installSchema('system', array('router')); // Create the comment body field storage. $this->installConfig(array('field')); } diff --git a/core/modules/config/src/Tests/ConfigCRUDTest.php b/core/modules/config/src/Tests/ConfigCRUDTest.php index c530b96..f42d722 100644 --- a/core/modules/config/src/Tests/ConfigCRUDTest.php +++ b/core/modules/config/src/Tests/ConfigCRUDTest.php @@ -39,11 +39,6 @@ class ConfigCRUDTest extends KernelTestBase { */ public static $modules = array('system'); - protected function setUp() { - parent::setUp(); - $this->installSchema('system', 'router'); - } - /** * Tests CRUD operations. */ diff --git a/core/modules/config/src/Tests/DefaultConfigTest.php b/core/modules/config/src/Tests/DefaultConfigTest.php index 2d5412c..99ff07a 100644 --- a/core/modules/config/src/Tests/DefaultConfigTest.php +++ b/core/modules/config/src/Tests/DefaultConfigTest.php @@ -45,7 +45,6 @@ class DefaultConfigTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', 'router'); \Drupal::service('theme_handler')->install($this->themes); } diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index 9cedc2d..ef0f476 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -26,7 +26,6 @@ class EntityDisplayTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installEntitySchema('node'); $this->installConfig(array('field')); } diff --git a/core/modules/filter/src/Tests/FilterAPITest.php b/core/modules/filter/src/Tests/FilterAPITest.php index 3ceb5eb..6ee11e2 100644 --- a/core/modules/filter/src/Tests/FilterAPITest.php +++ b/core/modules/filter/src/Tests/FilterAPITest.php @@ -28,7 +28,6 @@ class FilterAPITest extends EntityUnitTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installConfig(array('system', 'filter')); } diff --git a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php index f6902e39..97fe51f 100644 --- a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php +++ b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php @@ -30,7 +30,6 @@ class NodeImportCreateTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installEntitySchema('user'); // Set default storage backend. diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php index 8d2382e..218d0b9 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -21,7 +21,7 @@ class KernelTestBaseTest extends KernelTestBase { * * @var array */ - public static $modules = array('entity_test', 'system'); + public static $modules = array('entity_test'); /** * {@inheritdoc} @@ -44,7 +44,6 @@ function simpletest_test_stub_settings_function() {} $original_container = $this->originalContainer; parent::setUp(); - $this->installSchema('system', array('router')); $this->assertNotIdentical(\Drupal::getContainer(), $original_container, 'KernelTestBase test creates a new container.'); } @@ -52,7 +51,7 @@ function simpletest_test_stub_settings_function() {} * Tests expected behavior of setUp(). */ function testSetUp() { - $modules = array('entity_test', 'system'); + $modules = array('entity_test'); $table = 'entity_test'; // Verify that specified $modules have been loaded. diff --git a/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php b/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php index ea46747..f427ade 100644 --- a/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php +++ b/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php @@ -31,7 +31,6 @@ class FieldModuleUninstallValidatorTest extends EntityUnitTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', 'router'); $this->installSchema('user', 'users_data'); $this->entityDefinitionUpdateManager = $this->container->get('entity.definition_update_manager'); diff --git a/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php b/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php index b831830..2a34c20 100644 --- a/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php +++ b/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php @@ -16,16 +16,6 @@ */ class ModuleImplementsAlterTest extends KernelTestBase { - public static $modules = array('system'); - - /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - $this->installSchema('system', array('router')); - } - /** * Tests hook_module_implements_alter() adding an implementation. * diff --git a/core/modules/system/src/Tests/Routing/RouterTest.php b/core/modules/system/src/Tests/Routing/RouterTest.php index 85e5e4b..92e9608 100644 --- a/core/modules/system/src/Tests/Routing/RouterTest.php +++ b/core/modules/system/src/Tests/Routing/RouterTest.php @@ -194,6 +194,7 @@ public function testControllerResolutionAjax() { */ public function testRouterUninstallInstall() { \Drupal::service('module_installer')->uninstall(array('router_test')); + \Drupal::service('router.builder')->rebuild(); try { \Drupal::service('router.route_provider')->getRouteByName('router_test.1'); $this->fail('Route was delete on uninstall.'); @@ -203,6 +204,7 @@ public function testRouterUninstallInstall() { } // Install the module again. \Drupal::service('module_installer')->install(array('router_test')); + \Drupal::service('router.builder')->rebuild(); $route = \Drupal::service('router.route_provider')->getRouteByName('router_test.1'); $this->assertNotNull($route, 'Route exists after module installation'); } diff --git a/core/modules/system/src/Tests/System/InfoAlterTest.php b/core/modules/system/src/Tests/System/InfoAlterTest.php index 42f5041..02cdd17 100644 --- a/core/modules/system/src/Tests/System/InfoAlterTest.php +++ b/core/modules/system/src/Tests/System/InfoAlterTest.php @@ -19,14 +19,6 @@ class InfoAlterTest extends KernelTestBase { public static $modules = array('system'); /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - $this->installSchema('system', array('router')); - } - - /** * Tests that theme .info.yml data is rebuild after enabling a module. * * Tests that info data is rebuilt after a module that implements diff --git a/core/modules/system/src/Tests/System/TrustedHostsTest.php b/core/modules/system/src/Tests/System/TrustedHostsTest.php index 3719bd1..e54decc 100644 --- a/core/modules/system/src/Tests/System/TrustedHostsTest.php +++ b/core/modules/system/src/Tests/System/TrustedHostsTest.php @@ -69,6 +69,7 @@ public function testStatusPageWithConfiguration() { */ public function testFakeRequests() { $this->container->get('module_installer')->install(['trusted_hosts_test']); + $this->container->get('router.builder')->rebuild(); $host = $this->container->get('request_stack')->getCurrentRequest()->getHost(); $settings['settings']['trusted_host_patterns'] = (object) array( @@ -88,6 +89,7 @@ public function testFakeRequests() { public function testShortcut() { $this->container->get('module_installer')->install(['block', 'shortcut']); $this->rebuildContainer(); + $this->container->get('router.builder')->rebuild(); /** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */ $entity_manager = $this->container->get('entity.manager'); diff --git a/core/modules/system/src/Tests/Theme/RegistryTest.php b/core/modules/system/src/Tests/Theme/RegistryTest.php index 763372e..8872f10 100644 --- a/core/modules/system/src/Tests/Theme/RegistryTest.php +++ b/core/modules/system/src/Tests/Theme/RegistryTest.php @@ -28,15 +28,6 @@ class RegistryTest extends KernelTestBase { protected $profile = 'testing'; /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - - $this->installSchema('system', ['router']); - } - - /** * Tests the behavior of the theme registry class. */ function testRaceCondition() { diff --git a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php index 09d73e7..3ef48d0 100644 --- a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php @@ -34,7 +34,6 @@ class ThemeSettingsTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); // Theme settings rely on System module's system.theme.global configuration. $this->installConfig(array('system')); diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php index 3ca1dc4..94e981d 100644 --- a/core/modules/tracker/src/Tests/TrackerTest.php +++ b/core/modules/tracker/src/Tests/TrackerTest.php @@ -347,6 +347,7 @@ function testTrackerCronIndexing() { */ function testTrackerAdminUnpublish() { \Drupal::service('module_installer')->install(array('views')); + \Drupal::service('router.builder')->rebuild(); $admin_user = $this->drupalCreateUser(array('access content overview', 'administer nodes', 'bypass node access')); $this->drupalLogin($admin_user); diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php index 029a66c..2ef966a 100644 --- a/core/modules/user/src/Tests/UserCancelTest.php +++ b/core/modules/user/src/Tests/UserCancelTest.php @@ -72,6 +72,7 @@ function testUserCancelWithoutPermission() { */ public function testUserCancelChangePermission() { \Drupal::service('module_installer')->install(array('user_form_test')); + \Drupal::service('router.builder')->rebuild(); $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save(); // Create a regular user. @@ -96,6 +97,7 @@ public function testUserCancelChangePermission() { */ function testUserCancelUid1() { \Drupal::service('module_installer')->install(array('views')); + \Drupal::service('router.builder')->rebuild(); // Update uid 1's name and password to we know it. $password = user_password(); $account = array( @@ -453,6 +455,7 @@ function testUserWithoutEmailCancelByAdmin() { */ function testMassUserCancelByAdmin() { \Drupal::service('module_installer')->install(array('views')); + \Drupal::service('router.builder')->rebuild(); $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save(); // Enable account cancellation notification. $this->config('user.settings')->set('notify.status_canceled', TRUE)->save(); diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php index b8f212f..36cd9cd 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php @@ -290,6 +290,13 @@ public function setYamlDiscovery(YamlDiscovery $yaml_discovery) { $this->yamlDiscovery = $yaml_discovery; } + /** + * {@inheritdoc} + */ + protected function getRouteDefinitions() { + return $this->yamlDiscovery->findAll(); + } + } /**