Commit ae3dc626 authored by alexpott's avatar alexpott

Issue #2451665 by dawehner: Don't rebuild the route on...

Issue #2451665 by dawehner: Don't rebuild the route on ModuleInstaller::install() (30% installer speedup)
parent 1208ddd9
......@@ -281,7 +281,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));
}
......@@ -423,7 +423,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.
......
......@@ -44,13 +44,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.
*
......@@ -232,10 +225,10 @@ 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();
// Always instantiate a new YamlDiscovery object so that we always search on
// the up-to-date list of modules.
$discovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories());
return $discovery->findAll();
}
}
......@@ -30,7 +30,6 @@ class BookUninstallTest extends KernelTestBase {
*/
protected function setUp() {
parent::setUp();
$this->installSchema('system', array('router'));
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installSchema('book', array('book'));
......
......@@ -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(
......
......@@ -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'));
}
......
......@@ -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.
*/
......
......@@ -45,7 +45,6 @@ class DefaultConfigTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
$this->installSchema('system', 'router');
\Drupal::service('theme_handler')->install($this->themes);
}
......
......@@ -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', 'node'));
}
......
......@@ -29,7 +29,6 @@ class FilterAPITest extends EntityUnitTestBase {
protected function setUp() {
parent::setUp();
$this->installSchema('system', array('router'));
$this->installConfig(array('system', 'filter', 'filter_test'));
}
......
......@@ -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.
......
......@@ -21,7 +21,7 @@ class KernelTestBaseTest extends KernelTestBase {
*
* @var array
*/
public static $modules = array('entity_test', 'system');
public static $modules = array('entity_test');
/**
* {@inheritdoc}
......@@ -45,7 +45,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.');
}
......@@ -53,7 +52,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.
......
......@@ -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');
......
......@@ -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.
*
......
......@@ -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');
}
......
......@@ -18,14 +18,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.
*
......
......@@ -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');
......
......@@ -27,15 +27,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.
*/
......
......@@ -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'));
......
......@@ -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);
......
......@@ -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();
......
......@@ -352,6 +352,7 @@ public function testOutputIsEmpty() {
*/
public function testTranslationSetting() {
\Drupal::service('module_installer')->install(['file']);
\Drupal::service('router.builder')->rebuild();
// By default there should be no language settings.
$this->checkTranslationSetting();
......
......@@ -290,6 +290,13 @@ public function setYamlDiscovery(YamlDiscovery $yaml_discovery) {
$this->yamlDiscovery = $yaml_discovery;
}
/**
* {@inheritdoc}
*/
protected function getRouteDefinitions() {
return $this->yamlDiscovery->findAll();
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment