diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -302,8 +302,9 @@ // Allow command line scripts to override server variables used by Drupal. require_once __DIR__ . '/bootstrap.inc'; - // Prime the drupal_get_filename() cache with the location of the system - // module. + // Before having installed the system module and being able to do a module + // rebuild, prime the drupal_get_filename() static cache with the module's + // exact location. drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml'); // If the hash salt leaks, it becomes possible to forge a valid testing user @@ -1033,9 +1034,11 @@ // system.module in order to work. file_ensure_htaccess(); + // Before installing the user module, perform a module rebuild so we know + // where the user module is located. + system_rebuild_module_data(); // Enable the user module so that sessions can be recorded during the // upcoming bootstrap step. - system_rebuild_module_data(); \Drupal::service('module_installer')->install(array('user'), FALSE); // Save the list of other modules to install for the upcoming tasks. diff -u b/core/includes/install.inc b/core/includes/install.inc --- b/core/includes/install.inc +++ b/core/includes/install.inc @@ -923,6 +923,8 @@ // Collect requirement testing results. $requirements = array(); + // Performs an ExtensionDiscovery scan as the system module is unavailable and + // we don't yet know where all the modules are located. $listing = new ExtensionDiscovery(\Drupal::root()); $module_list = $listing->scan('module'); foreach ($info['dependencies'] as $module) { diff -u b/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php --- b/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -159,6 +159,8 @@ if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getCoreNames(); + // Perform an ExtensionDiscovery scan as we cannot use drupal_get_path() + // yet because the system module may not yet be enabled during install. $listing = new ExtensionDiscovery(\Drupal::root()); if ($profile = drupal_get_profile()) { $profile_list = $listing->scan('profile'); diff -u b/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php --- b/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -512,7 +512,8 @@ $themes = $this->moduleHandler->buildModuleDependencies($themes); // Store filenames to allow system_list() and drupal_get_filename() to - // retrieve them without having to scan the filesystem. + // retrieve them for themes and theme engines without having to scan the + // filesystem. $this->state->set('system.theme.files', $files_theme); $this->state->set('system.theme_engine.files', $files_theme_engine); diff -u b/core/modules/config/src/Tests/ConfigDependencyTest.php b/core/modules/config/src/Tests/ConfigDependencyTest.php --- b/core/modules/config/src/Tests/ConfigDependencyTest.php +++ b/core/modules/config/src/Tests/ConfigDependencyTest.php @@ -184,9 +184,11 @@ ) ); $entity2->save(); + // Perform a module rebuild so we can know where the node module is located. + // and uninstall it. + system_rebuild_module_data(); // Test that doing a config uninstall of the node module deletes entity2 // since it is dependent on entity1 which is dependent on the node module. - system_rebuild_module_data(); $config_manager->uninstall('module', 'node'); $this->assertFalse($storage->load('entity1'), 'Entity 1 deleted'); $this->assertFalse($storage->load('entity2'), 'Entity 2 deleted'); diff -u b/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php --- b/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -484,6 +484,9 @@ * The new modules are only added to the active module list and loaded. */ protected function enableModules(array $modules) { + // Perform an ExtensionDiscovery scan as this function may receive a + // profile that is not the current profile, and we don't yet have a cached + // way to receive inactive profile information. $listing = new ExtensionDiscovery(\Drupal::root()); $module_list = $listing->scan('module'); // In ModuleHandlerTest we pass in a profile as if it were a module. diff -u b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php --- b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php +++ b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php @@ -44,8 +44,11 @@ * The basic functionality of retrieving enabled modules. */ function testModuleList() { - // Build a list of modules, sorted alphabetically. + // Prime the drupal_get_filename() static cache with the location of the + // testing profile as it is not the currently active profile and we don't + // yet have any cached way to retrieve its location. drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml'); + // Build a list of modules, sorted alphabetically. $profile_info = install_profile_info('testing', 'en'); $module_list = $profile_info['dependencies']; @@ -192,6 +195,9 @@ $profile = 'minimal'; $dependency = 'dblog'; $this->settingsSet('install_profile', $profile); + // Prime the drupal_get_filename() static cache with the location of the + // minimal profile as it is not the currently active profile and we don't + // yet have any cached way to retrieve its location. drupal_get_filename('profile', 'minimal', 'core/profiles/' . $profile . '/' . $profile . '.info.yml'); $this->enableModules(array('module_test', $profile)); diff -u b/core/modules/system/src/Tests/File/ScanDirectoryTest.php b/core/modules/system/src/Tests/File/ScanDirectoryTest.php --- b/core/modules/system/src/Tests/File/ScanDirectoryTest.php +++ b/core/modules/system/src/Tests/File/ScanDirectoryTest.php @@ -28,6 +28,9 @@ protected function setUp() { parent::setUp(); + // Hardcode the location of the simpletest files as it is already known + // and shouldn't change, and we don't yet have a way to retreive their + // location from drupal_get_filename() in a cached way. $this->path = 'core/modules/simpletest/files'; } diff -u b/core/modules/system/src/Tests/Path/UrlAliasFixtures.php b/core/modules/system/src/Tests/Path/UrlAliasFixtures.php --- b/core/modules/system/src/Tests/Path/UrlAliasFixtures.php +++ b/core/modules/system/src/Tests/Path/UrlAliasFixtures.php @@ -81,7 +81,7 @@ $tables = array(); // Prime the drupal_get_filename() cache with the location of the system - // module. + // module as its location is known and shouldn't change. drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml'); module_load_install('system'); $schema = system_schema(); diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -884,11 +884,15 @@ function _system_rebuild_module_data() { $listing = new ExtensionDiscovery(\Drupal::root()); - // Find installation profiles. + // Find installation profiles. This needs to happen before + // performing a module scan as the module scan requires knowing + // what the active profile is. $profiles = $listing->scan('profile'); $profile = drupal_get_profile(); if ($profile && isset($profiles[$profile])) { - // Prime drupal_get_filename() with the profile info file location. + // Prime the drupal_get_filename() static cache with the profile info file + // location so we can use drupal_get_path() on the active profile during + // the module scan. drupal_get_filename('profile', $profile, $profiles[$profile]->getPathname()); }