diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index e353e7a..94c9ab5 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -911,9 +911,6 @@ function install_system_rebuild(&$install_state) { include DRUPAL_ROOT . '/' . $conf_path . '/settings.php'; } - // Unset the current service container. - drupal_container(NULL, TRUE); - // Reset module list and hook implementation statics. module_list_reset(); module_load_all(FALSE, TRUE); diff --git a/core/includes/install.inc b/core/includes/install.inc index 4fa35ff..c836100 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -410,15 +410,8 @@ function drupal_install_system() { $module = 'system'; $schema_store = drupal_container()->get('keyvalue')->get('system.schema'); - $module_config = config('system.module'); - $disabled_config = config('system.module.disabled'); + $module_filenames = drupal_container()->getParameter('container.modules'); - $module_config - ->set("enabled.$module", 0) - ->save(); - $disabled_config - ->clear($module) - ->save(); // Load the module's code. drupal_load('module', $module); @@ -426,12 +419,10 @@ function drupal_install_system() { system_list_reset(); module_implements_reset(); _system_update_bootstrap_status(); + // Update the kernel to include it. - // @todo The if statement is here because install_begin_request() creates - // a container without a kernel. It probably shouldn't. - if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { - $kernel->updateModules(module_list(), array($module => drupal_get_path('module', $module))); - } + $module_filenames[$module] = drupal_get_filename('module', $module); + drupal_container()->get('kernel')->updateModules(module_list(), $module_filenames); // Refresh the schema to include it. drupal_get_schema(NULL, TRUE); @@ -441,22 +432,38 @@ function drupal_install_system() { // Clear the entity info cache before importing new configuration. entity_info_cache_clear(); + // Set the schema version to the number of the last update provided + // by the module. + $versions = drupal_get_schema_versions($module); + $version = $versions ? max($versions) : SCHEMA_INSTALLED; + // Install default configuration of the module. config_install_default_config('module', $module); - // Set the schema version to the number of the last update provided. - $versions = drupal_get_schema_versions($module); - $version = $versions ? max($versions) : SCHEMA_INSTALLED; - $schema_store->set($module, $version); + // Unlike module_enable(), the entry in system.module:enabled can only be + // written after the default configuration has been installed, because the + // default configuration contains the system.module object itself and + // config_install_default_config() overwrites existing files in the target + // storage. + config('system.module') + ->set("enabled.$module", 0) + ->save(); + + // If the module has no current updates, but has some that were + // previously removed, set the version to the value of + // hook_update_last_removed(). + if ($last_removed = module_invoke($module, 'update_last_removed')) { + $version = max($version, $last_removed); + } + drupal_set_installed_schema_version($module, $version); // Allow the module to perform install tasks. module_invoke($module, 'install'); - + // Record the fact that it was installed. watchdog('system', '%module module installed.', array('%module' => $module), WATCHDOG_INFO); - entity_info_cache_clear(); - // Enable the module. + entity_info_cache_clear(); module_invoke($module, 'enable'); } diff --git a/core/includes/module.inc b/core/includes/module.inc index 9be96cd..fc726dc 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -517,13 +517,11 @@ function module_enable($module_list, $enable_dependencies = TRUE) { system_list_reset(); module_implements_reset(); _system_update_bootstrap_status(); - $module_filenames[$module] = drupal_get_filename('module', $module); + // Update the kernel to include it. - // @todo The if statement is here because install_begin_request() creates - // a container without a kernel. It probably shouldn't. - if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { - $kernel->updateModules(module_list(), $module_filenames); - } + $module_filenames[$module] = drupal_get_filename('module', $module); + drupal_container()->get('kernel')->updateModules(module_list(), $module_filenames); + // Refresh the schema to include it. drupal_get_schema(NULL, TRUE); // Update the theme registry to include it. diff --git a/core/modules/system/config/system.module.yml b/core/modules/system/config/system.module.yml index dc71340..01151d1 100644 --- a/core/modules/system/config/system.module.yml +++ b/core/modules/system/config/system.module.yml @@ -1,6 +1 @@ -enabled: - # @todo config_install_default_config() overwrites existing config. - # In case of System module, the installer needs to write this config file, - # before it can install default config. Therefore, system module MUST be - # contained in here already. - system: '0' +enabled: { }