summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--core/.phpstan-baseline.php6
-rw-r--r--core/includes/install.core.inc45
-rw-r--r--core/lib/Drupal/Core/Config/ConfigImporter.php36
-rw-r--r--core/lib/Drupal/Core/Config/ConfigInstaller.php219
-rw-r--r--core/lib/Drupal/Core/Config/ConfigInstallerInterface.php10
-rw-r--r--core/lib/Drupal/Core/Config/DefaultConfigMode.php59
-rw-r--r--core/lib/Drupal/Core/Extension/ModuleInstaller.php475
-rw-r--r--core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php4
-rw-r--r--core/lib/Drupal/Core/Theme/ThemeManager.php7
-rw-r--r--core/modules/announcements_feed/announcements_feed.info.yml1
-rw-r--r--core/modules/automated_cron/automated_cron.info.yml1
-rw-r--r--core/modules/ban/ban.info.yml1
-rw-r--r--core/modules/basic_auth/basic_auth.info.yml1
-rw-r--r--core/modules/big_pipe/big_pipe.info.yml1
-rw-r--r--core/modules/block/block.info.yml1
-rw-r--r--core/modules/block_content/block_content.info.yml1
-rw-r--r--core/modules/breakpoint/breakpoint.info.yml1
-rw-r--r--core/modules/ckeditor5/ckeditor5.info.yml1
-rw-r--r--core/modules/comment/comment.info.yml1
-rw-r--r--core/modules/config/config.info.yml1
-rw-r--r--core/modules/config/tests/config_import_test/config_import_test.module7
-rw-r--r--core/modules/config/tests/config_import_test/src/EventSubscriber.php2
-rw-r--r--core/modules/config/tests/src/Functional/ConfigImportUITest.php2
-rw-r--r--core/modules/config/tests/src/Functional/ConfigInstallWebTest.php19
-rw-r--r--core/modules/config_translation/config_translation.info.yml1
-rw-r--r--core/modules/contact/contact.info.yml1
-rw-r--r--core/modules/content_moderation/content_moderation.info.yml1
-rw-r--r--core/modules/content_translation/content_translation.info.yml2
-rw-r--r--core/modules/contextual/contextual.info.yml1
-rw-r--r--core/modules/datetime/datetime.info.yml1
-rw-r--r--core/modules/datetime_range/datetime_range.info.yml1
-rw-r--r--core/modules/dblog/dblog.info.yml1
-rw-r--r--core/modules/dynamic_page_cache/dynamic_page_cache.info.yml1
-rw-r--r--core/modules/editor/editor.info.yml1
-rw-r--r--core/modules/field/field.info.yml1
-rw-r--r--core/modules/field_layout/field_layout.info.yml1
-rw-r--r--core/modules/field_ui/field_ui.info.yml1
-rw-r--r--core/modules/file/file.info.yml1
-rw-r--r--core/modules/filter/filter.info.yml1
-rw-r--r--core/modules/help/help.info.yml1
-rw-r--r--core/modules/history/history.info.yml1
-rw-r--r--core/modules/image/image.info.yml1
-rw-r--r--core/modules/inline_form_errors/inline_form_errors.info.yml1
-rw-r--r--core/modules/jsonapi/jsonapi.info.yml1
-rw-r--r--core/modules/language/language.info.yml1
-rw-r--r--core/modules/layout_builder/layout_builder.info.yml1
-rw-r--r--core/modules/layout_discovery/layout_discovery.info.yml1
-rw-r--r--core/modules/link/link.info.yml1
-rw-r--r--core/modules/locale/locale.info.yml1
-rw-r--r--core/modules/media/media.info.yml1
-rw-r--r--core/modules/media_library/media_library.info.yml1
-rw-r--r--core/modules/menu_link_content/menu_link_content.info.yml1
-rw-r--r--core/modules/menu_ui/menu_ui.info.yml1
-rw-r--r--core/modules/migrate/migrate.info.yml1
-rw-r--r--core/modules/migrate_drupal/migrate_drupal.info.yml1
-rw-r--r--core/modules/migrate_drupal_ui/migrate_drupal_ui.info.yml1
-rw-r--r--core/modules/mysql/mysql.info.yml1
-rw-r--r--core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml1
-rw-r--r--core/modules/navigation/navigation.info.yml1
-rw-r--r--core/modules/node/node.info.yml1
-rw-r--r--core/modules/options/options.info.yml1
-rw-r--r--core/modules/package_manager/package_manager.info.yml1
-rw-r--r--core/modules/page_cache/page_cache.info.yml1
-rw-r--r--core/modules/path/path.info.yml1
-rw-r--r--core/modules/path_alias/path_alias.info.yml1
-rw-r--r--core/modules/pgsql/pgsql.info.yml1
-rw-r--r--core/modules/phpass/phpass.info.yml1
-rw-r--r--core/modules/responsive_image/responsive_image.info.yml1
-rw-r--r--core/modules/rest/rest.info.yml1
-rw-r--r--core/modules/sdc/sdc.info.yml1
-rw-r--r--core/modules/search/search.info.yml1
-rw-r--r--core/modules/serialization/serialization.info.yml1
-rw-r--r--core/modules/settings_tray/settings_tray.info.yml1
-rw-r--r--core/modules/shortcut/shortcut.info.yml1
-rw-r--r--core/modules/sqlite/sqlite.info.yml1
-rw-r--r--core/modules/syslog/syslog.info.yml1
-rw-r--r--core/modules/system/system.info.yml1
-rw-r--r--core/modules/system/tests/modules/container_rebuild_required_dependency_false/container_rebuild_required_dependency_false.info.yml8
-rw-r--r--core/modules/system/tests/modules/container_rebuild_required_false/container_rebuild_required_false.info.yml6
-rw-r--r--core/modules/system/tests/modules/container_rebuild_required_false_2/container_rebuild_required_false_2.info.yml6
-rw-r--r--core/modules/system/tests/modules/container_rebuild_required_true/container_rebuild_required_true.info.yml6
-rw-r--r--core/modules/system/tests/modules/container_rebuild_required_true_2/container_rebuild_required_true_2.info.yml6
-rw-r--r--core/modules/system/tests/modules/module_test/src/ModuleTestCompilerPass.php27
-rw-r--r--core/modules/system/tests/modules/module_test/src/ModuleTestServiceProvider.php22
-rw-r--r--core/modules/system/tests/src/Functional/Pager/PagerTest.php3
-rw-r--r--core/modules/taxonomy/taxonomy.info.yml1
-rw-r--r--core/modules/telephone/telephone.info.yml1
-rw-r--r--core/modules/text/text.info.yml1
-rw-r--r--core/modules/toolbar/toolbar.info.yml1
-rw-r--r--core/modules/update/update.info.yml1
-rw-r--r--core/modules/user/user.info.yml1
-rw-r--r--core/modules/views/views.info.yml1
-rw-r--r--core/modules/views_ui/views_ui.info.yml1
-rw-r--r--core/modules/workflows/workflows.info.yml1
-rw-r--r--core/modules/workspaces/workspaces.info.yml1
-rw-r--r--core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php38
-rw-r--r--core/tests/Drupal/KernelTests/KernelTestBase.php1
97 files changed, 772 insertions, 317 deletions
diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php
index b70afb2b499..2616ae77532 100644
--- a/core/.phpstan-baseline.php
+++ b/core/.phpstan-baseline.php
@@ -3243,12 +3243,6 @@ $ignoreErrors[] = [
];
$ignoreErrors[] = [
// identifier: missingType.return
- 'message' => '#^Method Drupal\\\\Core\\\\Config\\\\ConfigImporter\\:\\:processExtension\\(\\) has no return type specified\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/lib/Drupal/Core/Config/ConfigImporter.php',
-];
-$ignoreErrors[] = [
- // identifier: missingType.return
'message' => '#^Method Drupal\\\\Core\\\\Config\\\\ConfigImporter\\:\\:processExtensions\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/lib/Drupal/Core/Config/ConfigImporter.php',
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index ee1cacdded5..311fdb410c8 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1608,10 +1608,32 @@ function install_profile_modules(&$install_state) {
arsort($non_required);
$batch_builder = new BatchBuilder();
- foreach ($required + $non_required as $module => $weight) {
+
+ // Put modules into groups of up to the maximum batch size, or until a module
+ // states that it needs a container rebuild immediately after install.
+ $index = 0;
+ $module_groups = [];
+ foreach (array_keys($required + $non_required) as $module) {
+ $module_groups[$index][] = $module;
+ if (count($module_groups[$index]) === Settings::get('core.multi_module_install_batch_size', 20)) {
+ $index++;
+ }
+ // @todo Consider reversing this logic so that modules must explicitly
+ // state that they need a container build.
+ // @see https://www.drupal.org/project/drupal/issues/3492235
+ elseif (!isset($files[$module]->info['container_rebuild_required']) || $files[$module]->info['container_rebuild_required']) {
+ $index++;
+ }
+ }
+
+ foreach ($module_groups as $module_group) {
+ $names = [];
+ foreach ($module_group as $module) {
+ $names[] = $files[$module]->info['name'];
+ }
$batch_builder->addOperation(
'_install_module_batch',
- [$module, $files[$module]->info['name']],
+ [$module_group, $names],
);
}
$batch_builder
@@ -1912,10 +1934,10 @@ function install_finished(&$install_state) {
*
* Performs batch installation of modules.
*/
-function _install_module_batch($module, $module_name, &$context) {
- \Drupal::service('module_installer')->install([$module], FALSE);
- $context['results'][] = $module;
- $context['message'] = t('Installed %module module.', ['%module' => $module_name]);
+function _install_module_batch(array $modules, array $module_names, array &$context) {
+ \Drupal::service('module_installer')->install($modules, FALSE);
+ $context['results'] = array_merge($context['results'], $modules);
+ $context['message'] = \Drupal::translation()->formatPlural(count($module_names), 'Installed %module module.', 'Installed %module modules.', ['%module' => implode(', ', $module_names)]);
}
/**
@@ -2602,12 +2624,15 @@ function install_recipe_required_modules() {
// The system module is already installed. See install_base_system().
unset($required['system']);
+ $modules = [];
+ $names = [];
foreach ($required as $module => $weight) {
- $batch_builder->addOperation(
- '_install_module_batch',
- [$module, $files[$module]->info['name']],
- );
+ $modules[] = $module;
+ $names[] = $files[$module]->info['name'];
}
+ $batch_builder->addOperation('_install_module_batch',
+ [$modules, $names]
+ );
return $batch_builder->toArray();
}
diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php
index f16210fc8d9..3d9756ce775 100644
--- a/core/lib/Drupal/Core/Config/ConfigImporter.php
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -12,6 +12,7 @@ use Drupal\Core\Config\Entity\ImportableEntityStorageInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Lock\LockBackendInterface;
+use Drupal\Core\Site\Settings;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
@@ -366,11 +367,12 @@ class ConfigImporter {
* The type of extension, either 'theme' or 'module'.
* @param string $op
* The change operation performed, either install or uninstall.
- * @param string $name
- * The name of the extension processed.
+ * @param string|array $name
+ * The name or names of the extension(s) processed.
*/
protected function setProcessedExtension($type, $op, $name) {
- $this->processedExtensions[$type][$op][] = $name;
+ $name = (array) $name;
+ $this->processedExtensions[$type][$op] = array_merge($this->processedExtensions[$type][$op], $name);
}
/**
@@ -627,7 +629,11 @@ class ConfigImporter {
$operation = $this->getNextExtensionOperation();
if (!empty($operation)) {
$this->processExtension($operation['type'], $operation['op'], $operation['name']);
- $context['message'] = $this->t('Synchronizing extensions: @op @name.', ['@op' => $operation['op'], '@name' => $operation['name']]);
+ $names = implode(', ', (array) $operation['name']);
+ $context['message'] = match ($operation['op']) {
+ 'install' => $this->t('Synchronizing extensions: installed @name.', ['@name' => $names]),
+ 'uninstall' => $this->t('Synchronizing extensions: uninstalled @name.', ['@name' => $names]),
+ };
$processed_count = count($this->processedExtensions['module']['install']) + count($this->processedExtensions['module']['uninstall']);
$processed_count += count($this->processedExtensions['theme']['uninstall']) + count($this->processedExtensions['theme']['install']);
$context['finished'] = $processed_count / $this->totalExtensionsToProcess;
@@ -750,10 +756,16 @@ class ConfigImporter {
foreach ($types as $type) {
$unprocessed = $this->getUnprocessedExtensions($type);
if (!empty($unprocessed[$op])) {
+ if ($type === 'module' && $op === 'install') {
+ $name = array_slice($unprocessed[$op], 0, Settings::get('core.multi_module_install_batch_size', 20));
+ }
+ else {
+ $name = array_shift($unprocessed[$op]);
+ }
return [
'op' => $op,
'type' => $type,
- 'name' => array_shift($unprocessed[$op]),
+ 'name' => $name,
];
}
}
@@ -865,16 +877,17 @@ class ConfigImporter {
* The type of extension, either 'module' or 'theme'.
* @param string $op
* The change operation.
- * @param string $name
- * The name of the extension to process.
+ * @param string|array $names
+ * The name or names of the extension(s) to process.
*/
- protected function processExtension($type, $op, $name) {
+ protected function processExtension(string $type, string $op, string|array $names): void {
+ $names = (array) $names;
// Set the config installer to use the sync directory instead of the
// extensions own default config directories.
\Drupal::service('config.installer')
->setSourceStorage($this->storageComparer->getSourceStorage());
if ($type == 'module') {
- $this->moduleInstaller->$op([$name], FALSE);
+ $this->moduleInstaller->$op($names, FALSE);
// Installing a module can cause a kernel boot therefore inject all the
// services again.
$this->reInjectMe();
@@ -893,10 +906,9 @@ class ConfigImporter {
$this->configManager->getConfigFactory()->reset('system.theme');
$this->processedSystemTheme = TRUE;
}
- \Drupal::service('theme_installer')->$op([$name]);
+ \Drupal::service('theme_installer')->$op($names);
}
-
- $this->setProcessedExtension($type, $op, $name);
+ $this->setProcessedExtension($type, $op, $names);
}
/**
diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php
index 70933f8fb0e..82e33b0cad9 100644
--- a/core/lib/Drupal/Core/Config/ConfigInstaller.php
+++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php
@@ -105,7 +105,7 @@ class ConfigInstaller implements ConfigInstallerInterface {
/**
* {@inheritdoc}
*/
- public function installDefaultConfig($type, $name) {
+ public function installDefaultConfig($type, $name, DefaultConfigMode $mode = DefaultConfigMode::All) {
$extension_path = $this->extensionPathResolver->getPath($type, $name);
// Refresh the schema cache if the extension provides configuration schema
// or is a theme.
@@ -113,61 +113,97 @@ class ConfigInstaller implements ConfigInstallerInterface {
$this->typedConfig->clearCachedDefinitions();
}
- $default_install_path = $this->getDefaultConfigDirectory($type, $name);
- if (is_dir($default_install_path)) {
- if (!$this->isSyncing()) {
- $storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
- $prefix = '';
- }
- else {
- // The configuration importer sets the source storage on the config
- // installer. The configuration importer handles all of the
- // configuration entity imports. We only need to ensure that simple
- // configuration is created when the extension is installed.
- $storage = $this->getSourceStorage();
- $prefix = $name . '.';
- }
+ if ($mode->createInstallConfig()) {
+ $default_install_path = $this->getDefaultConfigDirectory($type, $name);
+ if (is_dir($default_install_path)) {
+ if (!$this->isSyncing()) {
+ $storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
+ $prefix = '';
+ }
+ else {
+ // The configuration importer sets the source storage on the config
+ // installer. The configuration importer handles all of the
+ // configuration entity imports. We only need to ensure that simple
+ // configuration is created when the extension is installed.
+ $storage = $this->getSourceStorage();
+ $prefix = $name . '.';
+ }
- // Gets profile storages to search for overrides if necessary.
- $profile_storages = $this->getProfileStorages($name);
+ // Gets profile storages to search for overrides if necessary.
+ $profile_storages = $this->getProfileStorages($name);
- // Gather information about all the supported collections.
- $collection_info = $this->configManager->getConfigCollectionInfo();
- foreach ($collection_info->getCollectionNames() as $collection) {
- $config_to_create = $this->getConfigToCreate($storage, $collection, $prefix, $profile_storages);
- if ($name == $this->drupalGetProfile()) {
- // If we're installing a profile ensure simple configuration that
- // already exists is excluded as it will have already been written.
- // This means that if the configuration is changed by something else
- // during the install it will not be overwritten again.
- $existing_configuration = array_filter($this->getActiveStorages($collection)->listAll(), function ($config_name) {
- return !$this->configManager->getEntityTypeIdByName($config_name);
- });
- $config_to_create = array_diff_key($config_to_create, array_flip($existing_configuration));
+ if ($mode === DefaultConfigMode::InstallEntities) {
+ // This is an optimization. If we're installing only config entities
+ // then we're only interested in the default collection.
+ $collections = [StorageInterface::DEFAULT_COLLECTION];
}
- if (!empty($config_to_create)) {
- $this->createConfiguration($collection, $config_to_create);
+ else {
+ // Gather information about all the supported collections.
+ $collections = $this->configManager->getConfigCollectionInfo()->getCollectionNames();
+ }
+
+ foreach ($collections as $collection) {
+ $config_to_create = $this->getConfigToCreate($storage, $collection, $prefix, $profile_storages);
+
+ if ($collection === StorageInterface::DEFAULT_COLLECTION && ($mode === DefaultConfigMode::InstallEntities || $mode === DefaultConfigMode::InstallSimple)) {
+ // Filter out config depending on the mode. The mode can be used to
+ // only install simple config or config entities.
+ $config_to_create = array_filter($config_to_create, function ($config_name) use ($mode) {
+ $is_config_entity = $this->configManager->getEntityTypeIdByName($config_name) !== NULL;
+ if ($is_config_entity) {
+ return $mode === DefaultConfigMode::InstallEntities;
+ }
+ return $mode === DefaultConfigMode::InstallSimple;
+ }, ARRAY_FILTER_USE_KEY);
+ }
+
+ if ($name === $this->drupalGetProfile()) {
+ // If we're installing a profile ensure simple configuration that
+ // already exists is excluded as it will have already been written.
+ // This means that if the configuration is changed by something else
+ // during the install it will not be overwritten again.
+ $existing_configuration = array_filter($this->getActiveStorages($collection)->listAll(), function ($config_name) {
+ return !$this->configManager->getEntityTypeIdByName($config_name);
+ });
+ $config_to_create = array_diff_key($config_to_create, array_flip($existing_configuration));
+ }
+
+ if (!empty($config_to_create)) {
+ $this->createConfiguration($collection, $config_to_create);
+ }
}
}
}
- // During a drupal installation optional configuration is installed at the
- // end of the installation process. Once the install profile is installed
- // optional configuration should be installed as usual.
- // @see install_install_profile()
- $profile_installed = in_array($this->drupalGetProfile(), $this->getEnabledExtensions(), TRUE);
- if (!$this->isSyncing() && (!InstallerKernel::installationAttempted() || $profile_installed)) {
- $optional_install_path = $extension_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
- if (is_dir($optional_install_path)) {
- // Install any optional config the module provides.
- $storage = new FileStorage($optional_install_path, StorageInterface::DEFAULT_COLLECTION);
- $this->installOptionalConfig($storage, '');
+ if ($mode->createOptionalConfig()) {
+ // During a drupal installation optional configuration is installed at the
+ // end of the installation process. Once the install profile is installed
+ // optional configuration should be installed as usual.
+ // @see install_install_profile()
+ $profile_installed = in_array($this->drupalGetProfile(), $this->getEnabledExtensions(), TRUE);
+ if (!$this->isSyncing() && (!InstallerKernel::installationAttempted() || $profile_installed)) {
+ $optional_install_path = $extension_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
+ if (is_dir($optional_install_path)) {
+ // Install any optional config the module provides.
+ $storage = new FileStorage($optional_install_path, StorageInterface::DEFAULT_COLLECTION);
+ $this->installOptionalConfig($storage, '');
+ }
+ }
+ }
+
+ if ($mode->createSiteOptionalConfig()) {
+ // During a drupal installation optional configuration is installed at the
+ // end of the installation process. Once the install profile is installed
+ // optional configuration should be installed as usual.
+ // @see install_install_profile()
+ $profile_installed = in_array($this->drupalGetProfile(), $this->getEnabledExtensions(), TRUE);
+ if (!$this->isSyncing() && (!InstallerKernel::installationAttempted() || $profile_installed)) {
+ // Install any optional configuration entities whose dependencies can now
+ // be met. This searches all the installed modules config/optional
+ // directories.
+ $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, FALSE, $this->installProfile);
+ $this->installOptionalConfig($storage, [$type => $name]);
}
- // Install any optional configuration entities whose dependencies can now
- // be met. This searches all the installed modules config/optional
- // directories.
- $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, FALSE, $this->installProfile);
- $this->installOptionalConfig($storage, [$type => $name]);
}
// Reset all the static caches and list caches.
@@ -370,6 +406,7 @@ class ConfigInstaller implements ConfigInstallerInterface {
if ($this->isSyncing()) {
continue;
}
+
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $entity_storage */
$entity_storage = $this->configManager
->getEntityTypeManager()
@@ -478,11 +515,16 @@ class ConfigInstaller implements ConfigInstallerInterface {
* it and the extension has been uninstalled and is about to the
* reinstalled.
*
+ * @param \Drupal\Core\Config\StorageInterface $storage
+ * The storage containing the default configuration.
+ * @param $previous_config_names
+ * An array of configuration names that have previously been checked.
+ *
* @return array
* Array of configuration object names that already exist keyed by
* collection.
*/
- protected function findPreExistingConfiguration(StorageInterface $storage) {
+ protected function findPreExistingConfiguration(StorageInterface $storage, array $previous_config_names = []) {
$existing_configuration = [];
// Gather information about all the supported collections.
$collection_info = $this->configManager->getConfigCollectionInfo();
@@ -491,7 +533,7 @@ class ConfigInstaller implements ConfigInstallerInterface {
$config_to_create = array_keys($this->getConfigToCreate($storage, $collection));
$active_storage = $this->getActiveStorages($collection);
foreach ($config_to_create as $config_name) {
- if ($active_storage->exists($config_name)) {
+ if ($active_storage->exists($config_name) || array_search($config_name, $previous_config_names[$collection] ?? [], TRUE) !== FALSE) {
$existing_configuration[$collection][] = $config_name;
}
}
@@ -508,34 +550,55 @@ class ConfigInstaller implements ConfigInstallerInterface {
// validation events.
return;
}
- $config_install_path = $this->getDefaultConfigDirectory($type, $name);
- if (!is_dir($config_install_path)) {
- return;
- }
+ $names = (array) $name;
+ $enabled_extensions = $this->getEnabledExtensions();
+ $previous_config_names = [];
- $storage = new FileStorage($config_install_path, StorageInterface::DEFAULT_COLLECTION);
+ foreach ($names as $name) {
+ // Add the extension that will be enabled to the list of enabled extensions.
+ $enabled_extensions[] = $name;
- $enabled_extensions = $this->getEnabledExtensions();
- // Add the extension that will be enabled to the list of enabled extensions.
- $enabled_extensions[] = $name;
- // Gets profile storages to search for overrides if necessary.
- $profile_storages = $this->getProfileStorages($name);
-
- // Check the dependencies of configuration provided by the module.
- [$invalid_default_config, $missing_dependencies] = $this->findDefaultConfigWithUnmetDependencies($storage, $enabled_extensions, $profile_storages);
- if (!empty($invalid_default_config)) {
- throw UnmetDependenciesException::create($name, array_unique($missing_dependencies, SORT_REGULAR));
- }
+ $config_install_path = $this->getDefaultConfigDirectory($type, $name);
+ if (!is_dir($config_install_path)) {
+ continue;
+ }
- // Install profiles can not have config clashes. Configuration that
- // has the same name as a module's configuration will be used instead.
- if ($name != $this->drupalGetProfile()) {
- // Throw an exception if the module being installed contains configuration
- // that already exists. Additionally, can not continue installing more
- // modules because those may depend on the current module being installed.
- $existing_configuration = $this->findPreExistingConfiguration($storage);
- if (!empty($existing_configuration)) {
- throw PreExistingConfigException::create($name, $existing_configuration);
+ $storage = new FileStorage($config_install_path, StorageInterface::DEFAULT_COLLECTION);
+
+ // Gets profile storages to search for overrides if necessary.
+ $profile_storages = $this->getProfileStorages($name);
+
+ // Check the dependencies of configuration provided by the module.
+ [
+ $invalid_default_config,
+ $missing_dependencies,
+ ] = $this->findDefaultConfigWithUnmetDependencies($storage, $enabled_extensions, $profile_storages, $previous_config_names);
+ if (!empty($invalid_default_config)) {
+ throw UnmetDependenciesException::create($name, array_unique($missing_dependencies, SORT_REGULAR));
+ }
+
+ // Install profiles can not have config clashes. Configuration that
+ // has the same name as a module's configuration will be used instead.
+ if ($name !== $this->drupalGetProfile()) {
+ // Throw an exception if the module being installed contains configuration
+ // that already exists. Additionally, can not continue installing more
+ // modules because those may depend on the current module being installed.
+ $existing_configuration = $this->findPreExistingConfiguration($storage, $previous_config_names);
+ if (!empty($existing_configuration)) {
+ throw PreExistingConfigException::create($name, $existing_configuration);
+ }
+ }
+
+ // Store the config names for the checked module in order to add them to
+ // the list of active configuration for the next module.
+ foreach ($this->configManager->getConfigCollectionInfo()->getCollectionNames() as $collection) {
+ $config_to_create = array_keys($this->getConfigToCreate($storage, $collection));
+ if (!isset($previous_config_names[$collection])) {
+ $previous_config_names[$collection] = $config_to_create;
+ }
+ else {
+ $previous_config_names[$collection] = array_merge($previous_config_names[$collection], $config_to_create);
+ }
}
}
}
@@ -550,6 +613,8 @@ class ConfigInstaller implements ConfigInstallerInterface {
* @param \Drupal\Core\Config\StorageInterface[] $profile_storages
* An array of storage interfaces containing profile configuration to check
* for overrides.
+ * @param string[][] $previously_checked_config
+ * A list of previously checked configuration. Keyed by collection name.
*
* @return array
* An array containing:
@@ -557,10 +622,10 @@ class ConfigInstaller implements ConfigInstallerInterface {
* - An array that will be filled with the missing dependency names, keyed
* by the dependents' names.
*/
- protected function findDefaultConfigWithUnmetDependencies(StorageInterface $storage, array $enabled_extensions, array $profile_storages = []) {
+ protected function findDefaultConfigWithUnmetDependencies(StorageInterface $storage, array $enabled_extensions, array $profile_storages = [], array $previously_checked_config = []) {
$missing_dependencies = [];
$config_to_create = $this->getConfigToCreate($storage, StorageInterface::DEFAULT_COLLECTION, '', $profile_storages);
- $all_config = array_merge($this->configFactory->listAll(), array_keys($config_to_create));
+ $all_config = array_merge($this->configFactory->listAll(), array_keys($config_to_create), $previously_checked_config[StorageInterface::DEFAULT_COLLECTION] ?? []);
foreach ($config_to_create as $config_name => $config) {
if ($missing = $this->getMissingDependencies($config_name, $config, $enabled_extensions, $all_config)) {
$missing_dependencies[$config_name] = $missing;
diff --git a/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php b/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php
index 5d90459d4f6..c4118dd36c4 100644
--- a/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php
+++ b/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php
@@ -27,10 +27,14 @@ interface ConfigInstallerInterface {
* The extension type; e.g., 'module' or 'theme'.
* @param string $name
* The name of the module or theme to install default configuration for.
+ * @param \Drupal\Core\Config\DefaultConfigMode $mode
+ * The default value DefaultConfigMode::All means create install, optional
+ * and site optional configuration. The other modes create a single type
+ * config.
*
* @see \Drupal\Core\Config\ExtensionInstallStorage
*/
- public function installDefaultConfig($type, $name);
+ public function installDefaultConfig($type, $name, DefaultConfigMode $mode = DefaultConfigMode::All);
/**
* Installs optional configuration.
@@ -108,8 +112,8 @@ interface ConfigInstallerInterface {
*
* @param string $type
* Type of extension to install.
- * @param string $name
- * Name of extension to install.
+ * @param string|array $name
+ * Name or names of extensions to install.
*
* @throws \Drupal\Core\Config\UnmetDependenciesException
* @throws \Drupal\Core\Config\PreExistingConfigException
diff --git a/core/lib/Drupal/Core/Config/DefaultConfigMode.php b/core/lib/Drupal/Core/Config/DefaultConfigMode.php
new file mode 100644
index 00000000000..4e8313e39a6
--- /dev/null
+++ b/core/lib/Drupal/Core/Config/DefaultConfigMode.php
@@ -0,0 +1,59 @@
+<?php
+
+declare(strict_types = 1);
+
+namespace Drupal\Core\Config;
+
+/**
+ * Provides modes for ConfigInstallerInterface::installDefaultConfig().
+ *
+ * @see \Drupal\Core\Config\ConfigInstallerInterface::installDefaultConfig()
+ */
+enum DefaultConfigMode {
+ case All;
+ case InstallSimple;
+ case InstallEntities;
+ case Optional;
+ case SiteOptional;
+
+ /**
+ * Determines if config in /install directory should be created.
+ *
+ * @return bool
+ * TRUE to create config in /install directory, FALSE if not.
+ */
+ public function createInstallConfig(): bool {
+ return match($this) {
+ DefaultConfigMode::All, DefaultConfigMode::InstallSimple, DefaultConfigMode::InstallEntities => TRUE,
+ default => FALSE,
+ };
+ }
+
+ /**
+ * Determines if config in /optional directory should be created.
+ *
+ * @return bool
+ * TRUE to create config in /optional directory, FALSE if not.
+ */
+ public function createOptionalConfig(): bool {
+ return match($this) {
+ DefaultConfigMode::All, DefaultConfigMode::Optional => TRUE,
+ default => FALSE,
+ };
+ }
+
+ /**
+ * Determines if optional config in other installed modules should be created.
+ *
+ * @return bool
+ * TRUE to create optional config in other installed modules,
+ * FALSE if not.
+ */
+ public function createSiteOptionalConfig(): bool {
+ return match($this) {
+ DefaultConfigMode::All, DefaultConfigMode::SiteOptional => TRUE,
+ default => FALSE,
+ };
+ }
+
+}
diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
index 7d19ebb41bb..1ae9ac54f26 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
@@ -4,6 +4,7 @@ namespace Drupal\Core\Extension;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Config\DefaultConfigMode;
use Drupal\Core\Database\Connection;
use Drupal\Core\DrupalKernelInterface;
use Drupal\Core\Entity\EntityStorageException;
@@ -120,6 +121,17 @@ class ModuleInstaller implements ModuleInstallerInterface {
*/
public function install(array $module_list, $enable_dependencies = TRUE) {
$extension_config = \Drupal::configFactory()->getEditable('core.extension');
+
+ // Remove any modules that are already installed.
+ $installed_modules = $extension_config->get('module') ?: [];
+ // Only process currently uninstalled modules.
+ $module_list = array_diff($module_list, array_keys($installed_modules));
+
+ if (empty($module_list)) {
+ // Nothing to do. All modules already installed.
+ return TRUE;
+ }
+
// Get all module data so we can find dependencies and sort and find the
// core requirements. The module list needs to be reset so that it can
// re-scan and include any new modules that may have been added directly
@@ -144,13 +156,6 @@ class ModuleInstaller implements ModuleInstallerInterface {
throw new MissingDependencyException(sprintf('Unable to install modules %s due to missing modules %s.', implode(', ', $module_list), implode(', ', $missing_modules)));
}
- // Only process currently uninstalled modules.
- $installed_modules = $extension_config->get('module') ?: [];
- if (!$module_list = array_diff_key($module_list, $installed_modules)) {
- // Nothing to do. All modules already installed.
- return TRUE;
- }
-
// Add dependencies to the list. The new modules will be processed as
// the foreach loop continues.
foreach ($module_list as $module => $value) {
@@ -186,213 +191,291 @@ class ModuleInstaller implements ModuleInstallerInterface {
/** @var \Drupal\Core\Config\ConfigInstaller $config_installer */
$config_installer = \Drupal::service('config.installer');
$sync_status = $config_installer->isSyncing();
- $modules_installed = [];
foreach ($module_list as $module) {
- $enabled = $extension_config->get("module.$module") !== NULL;
- if (!$enabled) {
- // Throw an exception if the module name is too long.
- if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) {
- throw new ExtensionNameLengthException("Module name '$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters');
- }
+ // Throw an exception if the module name is too long.
+ if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) {
+ throw new ExtensionNameLengthException("Module name '$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters');
+ }
- // Throw an exception if a theme with the same name is enabled.
- $installed_themes = $extension_config->get('theme') ?: [];
- if (isset($installed_themes[$module])) {
- throw new ExtensionNameReservedException("Module name $module is already in use by an installed theme.");
- }
+ // Throw an exception if a theme with the same name is enabled.
+ $installed_themes = $extension_config->get('theme') ?: [];
+ if (isset($installed_themes[$module])) {
+ throw new ExtensionNameReservedException("Module name $module is already in use by an installed theme.");
+ }
+ }
- // Load a new config object for each iteration, otherwise changes made
- // in hook_install() are not reflected in $extension_config.
- $extension_config = \Drupal::configFactory()->getEditable('core.extension');
-
- // Check the validity of the default configuration. This will throw
- // exceptions if the configuration is not valid.
- $config_installer->checkConfigurationToInstall('module', $module);
-
- // Save this data without checking schema. This is a performance
- // improvement for module installation.
- $extension_config
- ->set("module.$module", 0)
- ->set('module', module_config_sort($extension_config->get('module')))
- ->save(TRUE);
-
- // Prepare the new module list, sorted by weight, including filenames.
- // This list is used for both the ModuleHandler and DrupalKernel. It
- // needs to be kept in sync between both. A DrupalKernel reboot or
- // rebuild will automatically re-instantiate a new ModuleHandler that
- // uses the new module list of the kernel. However, DrupalKernel does
- // not cause any modules to be loaded.
- // Furthermore, the currently active (fixed) module list can be
- // different from the configured list of enabled modules. For all active
- // modules not contained in the configured enabled modules, we assume a
- // weight of 0.
- $current_module_filenames = $this->moduleHandler->getModuleList();
- $current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
- $current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module')));
- $module_filenames = [];
- foreach ($current_modules as $name => $weight) {
- if (isset($current_module_filenames[$name])) {
- $module_filenames[$name] = $current_module_filenames[$name];
- }
- else {
- $module_path = \Drupal::service('extension.list.module')->getPath($name);
- $pathname = "$module_path/$name.info.yml";
- $filename = file_exists($module_path . "/$name.module") ? "$name.module" : NULL;
- $module_filenames[$name] = new Extension($this->root, 'module', $pathname, $filename);
- }
- }
+ // Check the validity of the default configuration. This will throw
+ // exceptions if the configuration is not valid.
+ $config_installer->checkConfigurationToInstall('module', $module_list);
- // Update the module handler in order to have the correct module list
- // for the kernel update.
- $this->moduleHandler->setModuleList($module_filenames);
-
- // Clear the static cache of the "extension.list.module" service to pick
- // up the new module, since it merges the installation status of modules
- // into its statically cached list.
- \Drupal::service('extension.list.module')->reset();
-
- // Update the kernel to include it.
- $this->updateKernel($module_filenames);
-
- // Load the module's .module and .install files.
- $this->moduleHandler->load($module);
- $this->moduleHandler->loadInclude($module, 'install');
-
- if (!InstallerKernel::installationAttempted()) {
- // Replace the route provider service with a version that will rebuild
- // if routes used during installation. This ensures that a module's
- // routes are available during installation. This has to occur before
- // any services that depend on it are instantiated otherwise those
- // services will have the old route provider injected. Note that, since
- // the container is rebuilt by updating the kernel, the route provider
- // service is the regular one even though we are in a loop and might
- // have replaced it before.
- \Drupal::getContainer()->set('router.route_provider.old', \Drupal::service('router.route_provider'));
- \Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.lazy_builder'));
- }
+ // Some modules require a container rebuild immediately after install.
+ // Group modules such that as many are installed together as possible until
+ // one needs a container rebuild.
+ $module_groups = [];
+ $index = 0;
+ foreach ($module_list as $module) {
+ $module_groups[$index][] = $module;
+ // @todo Consider reversing the behavior when the info key is not set.
+ // See https://www.drupal.org/project/drupal/issues/3492235
+ if (!isset($module_data[$module]->info['container_rebuild_required']) || $module_data[$module]->info['container_rebuild_required']) {
+ $index++;
+ }
+ }
+ foreach ($module_groups as $modules) {
+ $this->doInstall($modules, $installed_modules, $sync_status);
+ // Refresh the installed modules list from configuration to preserve
+ // module weight.
+ $extension_config = \Drupal::configFactory()->getEditable('core.extension');
+ $installed_modules = $extension_config->get('module') ?: [];
+ }
+ if (!InstallerKernel::installationAttempted()) {
+ // 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'));
+ }
+ if (!\Drupal::service('router.route_provider.lazy_builder')->hasRebuilt()) {
+ // Rebuild routes after installing module. This is done here on top of
+ // \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on
+ // fastCGI which executes ::destruct() after the module installation
+ // page was sent already.
+ \Drupal::service('router.builder')->rebuild();
+ }
+ else {
+ // Rebuild the router immediately if it is marked as needing a rebuild.
+ // @todo Work this through a bit more. This fixes
+ // \Drupal\Tests\standard\Functional\StandardTest::testStandard()
+ // after separately out the optional configuration install.
+ \Drupal::service('router.builder')->rebuildIfNeeded();
+ }
+ }
- // Allow modules to react prior to the installation of a module.
- $this->invokeAll('module_preinstall', [$module, $sync_status]);
+ $this->moduleHandler->invokeAll('modules_installed', [$module_list, $sync_status]);
+ return TRUE;
+ }
- // Now install the module's schema if necessary.
- $this->installSchema($module);
+ /**
+ * Installs a set of modules.
+ *
+ * @param array $module_list
+ * The list of modules to install.
+ * @param array $installed_modules
+ * An array of the already installed modules.
+ * @param bool $sync_status
+ * The config sync status.
+ */
+ private function doInstall(array $module_list, array $installed_modules, bool $sync_status): void {
+ $extension_config = \Drupal::configFactory()->getEditable('core.extension');
- // Clear plugin manager caches.
- \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
+ // Save this data without checking schema. This is a performance
+ // improvement for module installation.
+ $extension_config
+ ->set('module', module_config_sort(array_merge(
+ array_fill_keys($module_list, 0),
+ $installed_modules
+ )))
+ ->save(TRUE);
+
+ // Prepare the new module list, sorted by weight, including filenames.
+ // This list is used for both the ModuleHandler and DrupalKernel. It
+ // needs to be kept in sync between both. A DrupalKernel reboot or
+ // rebuild will automatically re-instantiate a new ModuleHandler that
+ // uses the new module list of the kernel. However, DrupalKernel does
+ // not cause any modules to be loaded.
+ // Furthermore, the currently active (fixed) module list can be
+ // different from the configured list of enabled modules. For all active
+ // modules not contained in the configured enabled modules, we assume a
+ // weight of 0.
+ $current_module_filenames = $this->moduleHandler->getModuleList();
+ $current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
+ $current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module')));
+ $module_filenames = [];
+ foreach ($current_modules as $name => $weight) {
+ if (isset($current_module_filenames[$name])) {
+ $module_filenames[$name] = $current_module_filenames[$name];
+ }
+ else {
+ $module_path = \Drupal::service('extension.list.module')
+ ->getPath($name);
+ $pathname = "$module_path/$name.info.yml";
+ $filename = file_exists($module_path . "/$name.module") ? "$name.module" : NULL;
+ $module_filenames[$name] = new Extension($this->root, 'module', $pathname, $filename);
+ }
+ }
- // Set the schema version to the number of the last update provided by
- // the module, or the minimum core schema version.
- $version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION;
- $versions = $this->updateRegistry->getAvailableUpdates($module);
- if ($versions) {
- $version = max(max($versions), $version);
- }
+ // Update the module handler in order to have the correct module list
+ // for the kernel update.
+ $this->moduleHandler->setModuleList($module_filenames);
+
+ // Clear the static cache of the "extension.list.module" service to pick
+ // up the new module, since it merges the installation status of modules
+ // into its statically cached list.
+ \Drupal::service('extension.list.module')->reset();
+
+ // Update the kernel to include it.
+ $this->updateKernel($module_filenames);
+
+ if (!InstallerKernel::installationAttempted()) {
+ // Replace the route provider service with a version that will rebuild
+ // if routes are used during installation. This ensures that a module's
+ // routes are available during installation. This has to occur before
+ // any services that depend on it are instantiated otherwise those
+ // services will have the old route provider injected. Note that, since
+ // the container is rebuilt by updating the kernel, the route provider
+ // service is the regular one even though we are in a loop and might
+ // have replaced it before.
+ \Drupal::getContainer()->set('router.route_provider.old', \Drupal::service('router.route_provider'));
+ \Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.lazy_builder'));
+ }
- // Notify interested components that this module's entity types and
- // field storage definitions are new. For example, a SQL-based storage
- // handler can use this as an opportunity to create the necessary
- // database tables.
- // @todo Clean this up in https://www.drupal.org/node/2350111.
- $entity_type_manager = \Drupal::entityTypeManager();
- $update_manager = \Drupal::entityDefinitionUpdateManager();
- /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
- $entity_field_manager = \Drupal::service('entity_field.manager');
- foreach ($entity_type_manager->getDefinitions() as $entity_type) {
- $is_fieldable_entity_type = $entity_type->entityClassImplements(FieldableEntityInterface::class);
-
- if ($entity_type->getProvider() == $module) {
- if ($is_fieldable_entity_type) {
- $update_manager->installFieldableEntityType($entity_type, $entity_field_manager->getFieldStorageDefinitions($entity_type->id()));
- }
- else {
- $update_manager->installEntityType($entity_type);
- }
+ foreach ($module_list as $module) {
+ // Load the module's .module and .install files. Do this for all modules
+ // prior to calling hook_module_preinstall() in order to not pollute the
+ // cache.
+ $this->moduleHandler->load($module);
+ $this->moduleHandler->loadInclude($module, 'install');
+ }
+
+ foreach ($module_list as $module) {
+ // Allow modules to react prior to the installation of a module.
+ $this->moduleHandler->invokeAll('module_preinstall', [$module, $sync_status]);
+
+ // Now install the module's schema if necessary.
+ $this->installSchema($module);
+ }
+
+ // Clear plugin manager caches.
+ // @todo should this be in the loop?
+ \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
+
+ foreach ($module_list as $module) {
+ // Set the schema version to the number of the last update provided by
+ // the module, or the minimum core schema version.
+ $version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION;
+ $versions = $this->updateRegistry->getAvailableUpdates($module);
+ if ($versions) {
+ $version = max(max($versions), $version);
+ }
+
+ // Notify interested components that this module's entity types and
+ // field storage definitions are new. For example, a SQL-based storage
+ // handler can use this as an opportunity to create the necessary
+ // database tables.
+ // @todo Clean this up in https://www.drupal.org/node/2350111.
+ $entity_type_manager = \Drupal::entityTypeManager();
+ $update_manager = \Drupal::entityDefinitionUpdateManager();
+ /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
+ $entity_field_manager = \Drupal::service('entity_field.manager');
+ foreach ($entity_type_manager->getDefinitions() as $entity_type) {
+ $is_fieldable_entity_type = $entity_type->entityClassImplements(FieldableEntityInterface::class);
+
+ if ($entity_type->getProvider() == $module) {
+ if ($is_fieldable_entity_type) {
+ $update_manager->installFieldableEntityType($entity_type, $entity_field_manager->getFieldStorageDefinitions($entity_type->id()));
}
- elseif ($is_fieldable_entity_type) {
- // The module being installed may be adding new fields to existing
- // entity types. Field definitions for any entity type defined by
- // the module are handled in the if branch.
- foreach ($entity_field_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) {
- if ($storage_definition->getProvider() == $module) {
- // If the module being installed is also defining a storage key
- // for the entity type, the entity schema may not exist yet. It
- // will be created later in that case.
- try {
- $update_manager->installFieldStorageDefinition($storage_definition->getName(), $entity_type->id(), $module, $storage_definition);
- }
- catch (EntityStorageException $e) {
- Error::logException($this->logger, $e, 'An error occurred while notifying the creation of the @name field storage definition: "@message" in %function (line %line of %file).', ['@name' => $storage_definition->getName()]);
- }
+ else {
+ $update_manager->installEntityType($entity_type);
+ }
+ }
+ elseif ($is_fieldable_entity_type) {
+ // The module being installed may be adding new fields to existing
+ // entity types. Field definitions for any entity type defined by
+ // the module are handled in the if branch.
+ foreach ($entity_field_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) {
+ if ($storage_definition->getProvider() == $module) {
+ // If the module being installed is also defining a storage key
+ // for the entity type, the entity schema may not exist yet. It
+ // will be created later in that case.
+ try {
+ $update_manager->installFieldStorageDefinition($storage_definition->getName(), $entity_type->id(), $module, $storage_definition);
+ }
+ catch (EntityStorageException $e) {
+ Error::logException($this->logger, $e, 'An error occurred while notifying the creation of the @name field storage definition: "@message" in %function (line %line of %file).', ['@name' => $storage_definition->getName()]);
}
}
}
}
+ }
- // Install default configuration of the module.
- $config_installer = \Drupal::service('config.installer');
- $config_installer->installDefaultConfig('module', $module);
+ // Install default configuration of the module.
+ $config_installer = \Drupal::service('config.installer');
+ $config_installer->installDefaultConfig('module', $module, DefaultConfigMode::InstallSimple);
- // 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 = $this->invoke($module, 'update_last_removed')) {
- $version = max($version, $last_removed);
- }
- $this->updateRegistry->setInstalledVersion($module, $version);
+ // 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 = $this->invoke($module, 'update_last_removed')) {
+ $version = max($version, $last_removed);
+ }
+ $this->updateRegistry->setInstalledVersion($module, $version);
+ }
- // Record the fact that it was installed.
- $modules_installed[] = $module;
+ // Drupal's stream wrappers needs to be re-registered in case a
+ // module-provided stream wrapper is used later in the same request. In
+ // particular, this happens when installing Drupal via Drush, as the
+ // 'translations' stream wrapper is provided by Interface Translation
+ // module and is later used to import translations.
+ \Drupal::service('stream_wrapper_manager')->register();
- // Drupal's stream wrappers needs to be re-registered in case a
- // module-provided stream wrapper is used later in the same request. In
- // particular, this happens when installing Drupal via Drush, as the
- // 'translations' stream wrapper is provided by Interface Translation
- // module and is later used to import translations.
- \Drupal::service('stream_wrapper_manager')->register();
+ // Update the theme registry to include it.
+ \Drupal::service('theme.registry')->reset();
- // Update the theme registry to include it.
- \Drupal::service('theme.registry')->reset();
+ // Modules can alter theme info, so refresh theme data.
+ // @todo ThemeHandler cannot be injected into ModuleHandler, since that
+ // causes a circular service dependency.
+ // @see https://www.drupal.org/node/2208429
+ \Drupal::service('theme_handler')->refreshInfo();
- // Modules can alter theme info, so refresh theme data.
- // @todo ThemeHandler cannot be injected into ModuleHandler, since that
- // causes a circular service dependency.
- // @see https://www.drupal.org/node/2208429
- \Drupal::service('theme_handler')->refreshInfo();
+ // Modules may provide single directory components which are added to
+ // the core library definitions rather than the module itself, this
+ // requires the library discovery cache to be rebuilt.
+ \Drupal::service('library.discovery')->clear();
- // Modules may provide single directory components which are added to
- // the core library definitions rather than the module itself, this
- // requires the library discovery cache to be rebuilt.
- \Drupal::service('library.discovery')->clear();
+ $config_installer = \Drupal::service('config.installer');
+ foreach ($module_list as $module) {
+ // Create config entities a module has in the /install directory.
+ $config_installer->installDefaultConfig('module', $module, DefaultConfigMode::InstallEntities);
- // Allow the module to perform install tasks.
- $this->invoke($module, 'install', [$sync_status]);
+ // Allow the module to perform install tasks.
+ $this->invoke($module, 'install', [$sync_status]);
- // Record the fact that it was installed.
- \Drupal::logger('system')->info('%module module installed.', ['%module' => $module]);
- }
+ // Record the fact that it was installed.
+ \Drupal::logger('system')->info('%module module installed.', ['%module' => $module]);
}
- // If any modules were newly installed, invoke hook_modules_installed().
- if (!empty($modules_installed)) {
- if (!InstallerKernel::installationAttempted()) {
- // 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'));
- }
- if (!\Drupal::service('router.route_provider.lazy_builder')->hasRebuilt()) {
- // Rebuild routes after installing module. This is done here on top of
- // \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on
- // fastCGI which executes ::destruct() after the module installation
- // page was sent already.
- \Drupal::service('router.builder')->rebuild();
- }
- }
-
- $this->invokeAll('modules_installed', [$modules_installed, $sync_status]);
+ // Install optional configuration from modules once all the modules have
+ // been properly installed. This is often where soft dependencies lie.
+ // @todo This code fixes \Drupal\Tests\help\Functional\HelpTest::testHelp().
+ foreach ($module_list as $module) {
+ $config_installer->installDefaultConfig('module', $module, DefaultConfigMode::Optional);
+ }
+ // Install optional configuration from other modules once all the modules
+ // have been properly installed. This is often where soft dependencies lie.
+ // @todo This code fixes
+ // \Drupal\Tests\forum\Functional\Module\DependencyTest::testUninstallDependents().
+ foreach ($module_list as $module) {
+ $config_installer->installDefaultConfig('module', $module, DefaultConfigMode::SiteOptional);
}
- return TRUE;
+ if (count($module_list) > 1) {
+ // Reset the container so static caches are rebuilt. This prevents static
+ // caches like those in \Drupal\views\ViewsData() from having stale data.
+ // @todo Adding this code fixed
+ // \Drupal\KernelTests\Config\DefaultConfigTest::testModuleConfig().
+ // \Drupal\Component\DependencyInjection\Container::reset() seems to
+ // offer a way to do this but was broken for the following reasons:
+ // 1. Needs to set itself to 'service_container' like the constructor.
+ // 2. Needs to persist services, user and session like
+ // DrupalKernel::initializeContainer()
+ // 3. Needs to work out how to work with things like
+ // KernelTestBase::register() which set synthetic like services.
+ $this->updateKernel([]);
+
+ // Refresh anything cached with core.extension. This prevents caches in
+ // things like \Drupal\views\ViewsData() from having stale data.
+ // @todo This fixes \Drupal\Tests\views\Functional\ViewsFormAlterTest().
+ Cache::invalidateTags(['config:core.extension']);
+ }
}
/**
@@ -627,14 +710,20 @@ class ModuleInstaller implements ModuleInstallerInterface {
$sync_status = $config_installer->isSyncing();
$source_storage = $config_installer->getSourceStorage();
- // This reboots the kernel to register the module's bundle and its services
- // in the service container. The $module_filenames argument is taken over as
- // %container.modules% parameter, which is passed to a fresh ModuleHandler
- // instance upon first retrieval.
- $this->kernel->updateModules($module_filenames, $module_filenames);
+ if (!empty($module_filenames)) {
+ // This reboots the kernel to register the module's bundle and its services
+ // in the service container. The $module_filenames argument is taken over as
+ // %container.modules% parameter, which is passed to a fresh ModuleHandler
+ // instance upon first retrieval.
+ $this->kernel->updateModules($module_filenames, $module_filenames);
+ $container = $this->kernel->getContainer();
+ }
+ else {
+ $container = $this->kernel->resetContainer();
+ }
+
// After rebuilding the container we need to update the injected
// dependencies.
- $container = $this->kernel->getContainer();
$this->moduleHandler = $container->get('module_handler');
$this->connection = $container->get('database');
$this->updateRegistry = $container->get('update.update_hook_registry');
diff --git a/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php b/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php
index 76ce0ecb127..0497e112866 100644
--- a/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php
+++ b/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php
@@ -70,9 +70,9 @@ namespace Drupal\Core\ProxyClass\Config {
/**
* {@inheritdoc}
*/
- public function installDefaultConfig($type, $name)
+ public function installDefaultConfig($type, $name, \Drupal\Core\Config\DefaultConfigMode $mode = \Drupal\Core\Config\DefaultConfigMode::All)
{
- return $this->lazyLoadItself()->installDefaultConfig($type, $name);
+ return $this->lazyLoadItself()->installDefaultConfig($type, $name, $mode);
}
/**
diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php
index db36db950dd..576c1273dc7 100644
--- a/core/lib/Drupal/Core/Theme/ThemeManager.php
+++ b/core/lib/Drupal/Core/Theme/ThemeManager.php
@@ -131,13 +131,6 @@ class ThemeManager implements ThemeManagerInterface {
$active_theme = $this->getActiveTheme();
- // If called before all modules are loaded, we do not necessarily have a
- // full theme registry to work with, and therefore cannot process the theme
- // request properly. See also \Drupal\Core\Theme\Registry::get().
- if (!$this->moduleHandler->isLoaded() && !defined('MAINTENANCE_MODE')) {
- throw new \Exception('The theme implementations may not be rendered until all modules are loaded.');
- }
-
$theme_registry = $this->themeRegistry->getRuntime();
// If an array of hook candidates were passed, use the first one that has an
diff --git a/core/modules/announcements_feed/announcements_feed.info.yml b/core/modules/announcements_feed/announcements_feed.info.yml
index 328340f5add..671c2891e3e 100644
--- a/core/modules/announcements_feed/announcements_feed.info.yml
+++ b/core/modules/announcements_feed/announcements_feed.info.yml
@@ -2,4 +2,5 @@ name: Announcements
type: module
description: Displays announcements from the Drupal community.
version: VERSION
+container_rebuild_required: false
package: Core
diff --git a/core/modules/automated_cron/automated_cron.info.yml b/core/modules/automated_cron/automated_cron.info.yml
index 07f97f39f7a..8ce9c05dc55 100644
--- a/core/modules/automated_cron/automated_cron.info.yml
+++ b/core/modules/automated_cron/automated_cron.info.yml
@@ -3,4 +3,5 @@ type: module
description: 'Provides an automated way to run cron jobs, by executing them at the end of a server response.'
package: Core
version: VERSION
+container_rebuild_required: false
configure: system.cron_settings
diff --git a/core/modules/ban/ban.info.yml b/core/modules/ban/ban.info.yml
index 9a59be9b1f0..42139d339bd 100644
--- a/core/modules/ban/ban.info.yml
+++ b/core/modules/ban/ban.info.yml
@@ -3,4 +3,5 @@ type: module
description: 'Allows banning visits from specific IP addresses.'
package: Core
version: VERSION
+container_rebuild_required: false
configure: ban.admin_page
diff --git a/core/modules/basic_auth/basic_auth.info.yml b/core/modules/basic_auth/basic_auth.info.yml
index 638359ae48c..466f2ea47fe 100644
--- a/core/modules/basic_auth/basic_auth.info.yml
+++ b/core/modules/basic_auth/basic_auth.info.yml
@@ -3,5 +3,6 @@ type: module
description: 'Provides an HTTP Basic authentication provider.'
package: Web services
version: VERSION
+container_rebuild_required: false
dependencies:
- drupal:user
diff --git a/core/modules/big_pipe/big_pipe.info.yml b/core/modules/big_pipe/big_pipe.info.yml
index 5a5695c2968..b8658e7135b 100644
--- a/core/modules/big_pipe/big_pipe.info.yml
+++ b/core/modules/big_pipe/big_pipe.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Sends pages using the BigPipe technique that allows browsers to show them much faster.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/block/block.info.yml b/core/modules/block/block.info.yml
index ee7ccfe4556..09d74186166 100644
--- a/core/modules/block/block.info.yml
+++ b/core/modules/block/block.info.yml
@@ -3,4 +3,5 @@ type: module
description: 'Allows users to configure blocks (containing content, forms, etc.) and to place them in the regions of a theme.'
package: Core
version: VERSION
+container_rebuild_required: false
configure: block.admin_display
diff --git a/core/modules/block_content/block_content.info.yml b/core/modules/block_content/block_content.info.yml
index eb68ec90f0c..84ba7827ce4 100644
--- a/core/modules/block_content/block_content.info.yml
+++ b/core/modules/block_content/block_content.info.yml
@@ -3,6 +3,7 @@ type: module
description: 'Allows the creation of content blocks and block types.'
package: Core
version: VERSION
+container_rebuild_required: false
dependencies:
- drupal:block
- drupal:text
diff --git a/core/modules/breakpoint/breakpoint.info.yml b/core/modules/breakpoint/breakpoint.info.yml
index 7b55d32b9fe..465a30e13dc 100644
--- a/core/modules/breakpoint/breakpoint.info.yml
+++ b/core/modules/breakpoint/breakpoint.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Manages breakpoints and breakpoint groups for responsive designs.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/ckeditor5/ckeditor5.info.yml b/core/modules/ckeditor5/ckeditor5.info.yml
index a01882e92e0..ffba5cc8ac1 100644
--- a/core/modules/ckeditor5/ckeditor5.info.yml
+++ b/core/modules/ckeditor5/ckeditor5.info.yml
@@ -2,6 +2,7 @@ name: CKEditor 5
type: module
description: "Provides the CKEditor 5 rich text editor."
version: VERSION
+container_rebuild_required: false
package: Core
dependencies:
- drupal:editor
diff --git a/core/modules/comment/comment.info.yml b/core/modules/comment/comment.info.yml
index 12ff94b4f09..53002faf53f 100644
--- a/core/modules/comment/comment.info.yml
+++ b/core/modules/comment/comment.info.yml
@@ -3,6 +3,7 @@ type: module
description: 'Allows users to comment on content.'
package: Core
version: VERSION
+container_rebuild_required: false
dependencies:
- drupal:text
configure: comment.admin
diff --git a/core/modules/config/config.info.yml b/core/modules/config/config.info.yml
index add63ddd1a3..08d7fb3fda2 100644
--- a/core/modules/config/config.info.yml
+++ b/core/modules/config/config.info.yml
@@ -3,4 +3,5 @@ type: module
description: 'Allows importing and exporting configuration changes.'
package: Core
version: VERSION
+container_rebuild_required: false
configure: config.sync
diff --git a/core/modules/config/tests/config_import_test/config_import_test.module b/core/modules/config/tests/config_import_test/config_import_test.module
index efb5f189ada..7b33703e560 100644
--- a/core/modules/config/tests/config_import_test/config_import_test.module
+++ b/core/modules/config/tests/config_import_test/config_import_test.module
@@ -25,3 +25,10 @@ function _config_import_test_config_import_steps_alter(&$context, ConfigImporter
}
$context['finished'] = 1;
}
+
+/**
+ * Implements hook_modules_installed().
+ */
+function config_import_test_modules_installed($modules, $is_syncing): void {
+ \Drupal::state()->set('config_import_test_modules_installed.list', $modules);
+}
diff --git a/core/modules/config/tests/config_import_test/src/EventSubscriber.php b/core/modules/config/tests/config_import_test/src/EventSubscriber.php
index f305369a9bc..593402f026d 100644
--- a/core/modules/config/tests/config_import_test/src/EventSubscriber.php
+++ b/core/modules/config/tests/config_import_test/src/EventSubscriber.php
@@ -103,7 +103,7 @@ class EventSubscriber implements EventSubscriberInterface {
$data = $config->get('module');
$install = array_diff_key($data, $original);
if (!empty($install)) {
- $installed[] = key($install);
+ $installed = array_merge($installed, $install);
}
$uninstall = array_diff_key($original, $data);
if (!empty($uninstall)) {
diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php
index b5486e86e55..c72e270779b 100644
--- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php
@@ -162,9 +162,9 @@ class ConfigImportUITest extends BrowserTestBase {
$this->assertTrue(\Drupal::service('theme_handler')->themeExists('olivero'), 'Olivero theme installed during import.');
// Ensure installations and uninstallation occur as expected.
- $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', []);
$uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
$expected = ['automated_cron', 'ban', 'text', 'options'];
+ $installed = \Drupal::state()->get('config_import_test_modules_installed.list');
$this->assertSame($expected, $installed, 'Automated Cron, Ban, Text and Options modules installed in the correct order.');
$this->assertEmpty($uninstalled, 'No modules uninstalled during import');
diff --git a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
index 80a5221c74a..f2089984da6 100644
--- a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
@@ -147,13 +147,11 @@ class ConfigInstallWebTest extends BrowserTestBase {
'modules[config_test][enable]' => TRUE,
'modules[config_install_fail_test][enable]' => TRUE,
], 'Install');
+ // @todo improve error message as the config does not exist. But both modules
+ // being installed have the same configuration object and therefore we
+ // cannot install both together.
$this->assertSession()->responseContains('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
- // Uninstall the config_test module to test the confirm form.
- $this->drupalGet('admin/modules/uninstall');
- $this->submitForm(['uninstall[config_test]' => TRUE], 'Uninstall');
- $this->submitForm([], 'Uninstall');
-
// Try to install config_install_fail_test without selecting config_test.
// The user is shown a confirm form because the config_test module is a
// dependency.
@@ -161,8 +159,19 @@ class ConfigInstallWebTest extends BrowserTestBase {
$this->drupalGet('admin/modules');
$this->submitForm(['modules[config_install_fail_test][enable]' => TRUE], 'Install');
$this->submitForm([], 'Continue');
+ // @todo improve error message as the config does not exist. But both modules
+ // being installed have the same configuration object and therefore we
+ // cannot install both together.
$this->assertSession()->responseContains('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
+ // Install the config test module so that the configuration does actually
+ // exist.
+ $this->drupalGet('admin/modules');
+ $this->submitForm([
+ 'modules[config_test][enable]' => TRUE,
+ ], 'Install');
+ $this->assertSession()->responseContains('Module <em class="placeholder">Configuration test</em> has been installed.');
+
// Test that collection configuration clashes during a module install are
// reported correctly.
\Drupal::service('module_installer')->install(['language']);
diff --git a/core/modules/config_translation/config_translation.info.yml b/core/modules/config_translation/config_translation.info.yml
index 2a502a93371..90fcbc566ca 100644
--- a/core/modules/config_translation/config_translation.info.yml
+++ b/core/modules/config_translation/config_translation.info.yml
@@ -3,6 +3,7 @@ type: module
description: 'Allows users to translate configuration text.'
package: Multilingual
version: VERSION
+container_rebuild_required: false
configure: config_translation.mapper_list
dependencies:
- drupal:locale
diff --git a/core/modules/contact/contact.info.yml b/core/modules/contact/contact.info.yml
index 38d010868c3..2facbd74a28 100644
--- a/core/modules/contact/contact.info.yml
+++ b/core/modules/contact/contact.info.yml
@@ -3,4 +3,5 @@ type: module
description: 'Provides site-wide contact forms and forms to contact individual users.'
package: Core
version: VERSION
+container_rebuild_required: false
configure: entity.contact_form.collection
diff --git a/core/modules/content_moderation/content_moderation.info.yml b/core/modules/content_moderation/content_moderation.info.yml
index c5c0f06d0c3..dd1893cf649 100644
--- a/core/modules/content_moderation/content_moderation.info.yml
+++ b/core/modules/content_moderation/content_moderation.info.yml
@@ -2,6 +2,7 @@ name: 'Content Moderation'
type: module
description: 'Provides additional publication states that can be used by other modules to moderate content.'
version: VERSION
+container_rebuild_required: false
package: Core
configure: entity.workflow.collection
dependencies:
diff --git a/core/modules/content_translation/content_translation.info.yml b/core/modules/content_translation/content_translation.info.yml
index cc260aa9e3a..e38d9ddcd60 100644
--- a/core/modules/content_translation/content_translation.info.yml
+++ b/core/modules/content_translation/content_translation.info.yml
@@ -3,6 +3,8 @@ type: module
description: 'Allows users to translate content.'
dependencies:
- drupal:language
+ - drupal:path_alias
package: Multilingual
version: VERSION
+container_rebuild_required: false
configure: language.content_settings_page
diff --git a/core/modules/contextual/contextual.info.yml b/core/modules/contextual/contextual.info.yml
index 47888b231a3..c3849150dfb 100644
--- a/core/modules/contextual/contextual.info.yml
+++ b/core/modules/contextual/contextual.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides contextual links to directly access tasks related to page elements.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/datetime/datetime.info.yml b/core/modules/datetime/datetime.info.yml
index f8fc06703b4..408a00e1803 100644
--- a/core/modules/datetime/datetime.info.yml
+++ b/core/modules/datetime/datetime.info.yml
@@ -3,5 +3,6 @@ type: module
description: 'Defines field types for storing dates and times.'
package: Field types
version: VERSION
+container_rebuild_required: false
dependencies:
- drupal:field
diff --git a/core/modules/datetime_range/datetime_range.info.yml b/core/modules/datetime_range/datetime_range.info.yml
index 1d0596a7fb8..223fedcd41f 100644
--- a/core/modules/datetime_range/datetime_range.info.yml
+++ b/core/modules/datetime_range/datetime_range.info.yml
@@ -3,5 +3,6 @@ type: module
description: 'Provides the ability to store end dates.'
package: Field types
version: VERSION
+container_rebuild_required: false
dependencies:
- drupal:datetime
diff --git a/core/modules/dblog/dblog.info.yml b/core/modules/dblog/dblog.info.yml
index 1523a48f873..5e798c4204c 100644
--- a/core/modules/dblog/dblog.info.yml
+++ b/core/modules/dblog/dblog.info.yml
@@ -3,4 +3,5 @@ type: module
description: 'Logs system events in the database.'
package: Core
version: VERSION
+container_rebuild_required: false
configure: system.logging_settings
diff --git a/core/modules/dynamic_page_cache/dynamic_page_cache.info.yml b/core/modules/dynamic_page_cache/dynamic_page_cache.info.yml
index b20faf7994e..d13a738f284 100644
--- a/core/modules/dynamic_page_cache/dynamic_page_cache.info.yml
+++ b/core/modules/dynamic_page_cache/dynamic_page_cache.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Caches pages, including those with dynamic content, for all users.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/editor/editor.info.yml b/core/modules/editor/editor.info.yml
index 38267555fcf..2a4949fbf9b 100644
--- a/core/modules/editor/editor.info.yml
+++ b/core/modules/editor/editor.info.yml
@@ -7,3 +7,4 @@ dependencies:
- drupal:filter
- drupal:file
configure: filter.admin_overview
+container_rebuild_required: false
diff --git a/core/modules/field/field.info.yml b/core/modules/field/field.info.yml
index 368a877f5e4..d8c95e37186 100644
--- a/core/modules/field/field.info.yml
+++ b/core/modules/field/field.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides the capabilities to add fields to entities.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/field_layout/field_layout.info.yml b/core/modules/field_layout/field_layout.info.yml
index 88fd2047159..b885ea737b2 100644
--- a/core/modules/field_layout/field_layout.info.yml
+++ b/core/modules/field_layout/field_layout.info.yml
@@ -6,3 +6,4 @@ lifecycle: experimental
version: VERSION
dependencies:
- drupal:layout_discovery
+container_rebuild_required: false
diff --git a/core/modules/field_ui/field_ui.info.yml b/core/modules/field_ui/field_ui.info.yml
index 3642c59fcb5..552650efe19 100644
--- a/core/modules/field_ui/field_ui.info.yml
+++ b/core/modules/field_ui/field_ui.info.yml
@@ -5,3 +5,4 @@ package: Core
version: VERSION
dependencies:
- drupal:field
+container_rebuild_required: false
diff --git a/core/modules/file/file.info.yml b/core/modules/file/file.info.yml
index 0ce8c1a3c42..f86f0442949 100644
--- a/core/modules/file/file.info.yml
+++ b/core/modules/file/file.info.yml
@@ -5,3 +5,4 @@ package: Field types
version: VERSION
dependencies:
- drupal:field
+container_rebuild_required: false
diff --git a/core/modules/filter/filter.info.yml b/core/modules/filter/filter.info.yml
index 7a292893b2e..2504bde5a59 100644
--- a/core/modules/filter/filter.info.yml
+++ b/core/modules/filter/filter.info.yml
@@ -6,3 +6,4 @@ version: VERSION
configure: filter.admin_overview
dependencies:
- drupal:user
+container_rebuild_required: false
diff --git a/core/modules/help/help.info.yml b/core/modules/help/help.info.yml
index 1f56f87d1e6..4aa0024899b 100644
--- a/core/modules/help/help.info.yml
+++ b/core/modules/help/help.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Generates help pages and provides a Help block with page-level help.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/history/history.info.yml b/core/modules/history/history.info.yml
index 5c24051ba27..913304bad99 100644
--- a/core/modules/history/history.info.yml
+++ b/core/modules/history/history.info.yml
@@ -5,3 +5,4 @@ package: Core
version: VERSION
dependencies:
- drupal:node
+container_rebuild_required: false
diff --git a/core/modules/image/image.info.yml b/core/modules/image/image.info.yml
index 24b13033dc3..d8c42675bd1 100644
--- a/core/modules/image/image.info.yml
+++ b/core/modules/image/image.info.yml
@@ -6,3 +6,4 @@ version: VERSION
dependencies:
- drupal:file
configure: entity.image_style.collection
+container_rebuild_required: false
diff --git a/core/modules/inline_form_errors/inline_form_errors.info.yml b/core/modules/inline_form_errors/inline_form_errors.info.yml
index 0e8cee04c7e..50de3ecaa36 100644
--- a/core/modules/inline_form_errors/inline_form_errors.info.yml
+++ b/core/modules/inline_form_errors/inline_form_errors.info.yml
@@ -3,3 +3,4 @@ name: Inline Form Errors
description: 'Places error messages adjacent to form inputs, for improved usability and accessibility.'
version: VERSION
package: Core
+container_rebuild_required: false
diff --git a/core/modules/jsonapi/jsonapi.info.yml b/core/modules/jsonapi/jsonapi.info.yml
index 5296de6b256..ff1c934bdcf 100644
--- a/core/modules/jsonapi/jsonapi.info.yml
+++ b/core/modules/jsonapi/jsonapi.info.yml
@@ -7,3 +7,4 @@ configure: jsonapi.settings
dependencies:
- drupal:serialization
- drupal:file
+container_rebuild_required: false
diff --git a/core/modules/language/language.info.yml b/core/modules/language/language.info.yml
index 4d1abc993d6..16207c73751 100644
--- a/core/modules/language/language.info.yml
+++ b/core/modules/language/language.info.yml
@@ -4,3 +4,4 @@ description: 'Allows users to configure available languages.'
package: Multilingual
version: VERSION
configure: entity.configurable_language.collection
+container_rebuild_required: false
diff --git a/core/modules/layout_builder/layout_builder.info.yml b/core/modules/layout_builder/layout_builder.info.yml
index 0a6e43ea3b2..4de2601045b 100644
--- a/core/modules/layout_builder/layout_builder.info.yml
+++ b/core/modules/layout_builder/layout_builder.info.yml
@@ -8,3 +8,4 @@ dependencies:
- drupal:contextual
# @todo Discuss removing in https://www.drupal.org/project/drupal/issues/3003610.
- drupal:block
+container_rebuild_required: false
diff --git a/core/modules/layout_discovery/layout_discovery.info.yml b/core/modules/layout_discovery/layout_discovery.info.yml
index 71de940794d..102151f952d 100644
--- a/core/modules/layout_discovery/layout_discovery.info.yml
+++ b/core/modules/layout_discovery/layout_discovery.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides a way for modules or themes to register layouts.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/link/link.info.yml b/core/modules/link/link.info.yml
index ca6d4390dc5..27a15e470f9 100644
--- a/core/modules/link/link.info.yml
+++ b/core/modules/link/link.info.yml
@@ -5,3 +5,4 @@ package: Field types
version: VERSION
dependencies:
- drupal:field
+container_rebuild_required: false
diff --git a/core/modules/locale/locale.info.yml b/core/modules/locale/locale.info.yml
index e5530e0c779..3625a5e763c 100644
--- a/core/modules/locale/locale.info.yml
+++ b/core/modules/locale/locale.info.yml
@@ -7,3 +7,4 @@ version: VERSION
dependencies:
- drupal:language
- drupal:file
+container_rebuild_required: false
diff --git a/core/modules/media/media.info.yml b/core/modules/media/media.info.yml
index 6d5ea6ea7d9..8da914a3039 100644
--- a/core/modules/media/media.info.yml
+++ b/core/modules/media/media.info.yml
@@ -8,3 +8,4 @@ dependencies:
- drupal:image
- drupal:user
configure: media.settings
+container_rebuild_required: false
diff --git a/core/modules/media_library/media_library.info.yml b/core/modules/media_library/media_library.info.yml
index 4a9859fe07d..24bd6446365 100644
--- a/core/modules/media_library/media_library.info.yml
+++ b/core/modules/media_library/media_library.info.yml
@@ -8,3 +8,4 @@ dependencies:
- drupal:media
- drupal:views
- drupal:user
+container_rebuild_required: false
diff --git a/core/modules/menu_link_content/menu_link_content.info.yml b/core/modules/menu_link_content/menu_link_content.info.yml
index 1ea2e1db147..4ba779d84b9 100644
--- a/core/modules/menu_link_content/menu_link_content.info.yml
+++ b/core/modules/menu_link_content/menu_link_content.info.yml
@@ -5,3 +5,4 @@ package: Core
version: VERSION
dependencies:
- drupal:link
+container_rebuild_required: false
diff --git a/core/modules/menu_ui/menu_ui.info.yml b/core/modules/menu_ui/menu_ui.info.yml
index 249621436bf..eb01b9bdb12 100644
--- a/core/modules/menu_ui/menu_ui.info.yml
+++ b/core/modules/menu_ui/menu_ui.info.yml
@@ -6,3 +6,4 @@ version: VERSION
configure: entity.menu.collection
dependencies:
- drupal:menu_link_content
+container_rebuild_required: false
diff --git a/core/modules/migrate/migrate.info.yml b/core/modules/migrate/migrate.info.yml
index 161fb07ed17..079b6abd77d 100644
--- a/core/modules/migrate/migrate.info.yml
+++ b/core/modules/migrate/migrate.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides a framework for migrating data to Drupal.'
package: Migration
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/migrate_drupal/migrate_drupal.info.yml b/core/modules/migrate_drupal/migrate_drupal.info.yml
index 843e87102f8..219f0502db3 100644
--- a/core/modules/migrate_drupal/migrate_drupal.info.yml
+++ b/core/modules/migrate_drupal/migrate_drupal.info.yml
@@ -6,3 +6,4 @@ version: VERSION
dependencies:
- drupal:migrate
- drupal:phpass
+container_rebuild_required: false
diff --git a/core/modules/migrate_drupal_ui/migrate_drupal_ui.info.yml b/core/modules/migrate_drupal_ui/migrate_drupal_ui.info.yml
index 1ddccc51f02..67896f43d1a 100644
--- a/core/modules/migrate_drupal_ui/migrate_drupal_ui.info.yml
+++ b/core/modules/migrate_drupal_ui/migrate_drupal_ui.info.yml
@@ -8,3 +8,4 @@ dependencies:
- drupal:migrate
- drupal:migrate_drupal
- drupal:dblog
+container_rebuild_required: false
diff --git a/core/modules/mysql/mysql.info.yml b/core/modules/mysql/mysql.info.yml
index 57f13deb96d..c8c76129749 100644
--- a/core/modules/mysql/mysql.info.yml
+++ b/core/modules/mysql/mysql.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides the MySQL database driver.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml b/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml
index edaabb1e223..39783ad3149 100644
--- a/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml
+++ b/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml
@@ -4,6 +4,7 @@ description: 'When enabled, this module provides relevant administrative informa
package: Core (Experimental)
lifecycle: experimental
version: VERSION
+container_rebuild_required: false
dependencies:
- navigation:navigation
hidden: true
diff --git a/core/modules/navigation/navigation.info.yml b/core/modules/navigation/navigation.info.yml
index fde93502027..f55823bdb90 100644
--- a/core/modules/navigation/navigation.info.yml
+++ b/core/modules/navigation/navigation.info.yml
@@ -9,3 +9,4 @@ dependencies:
- drupal:block
- drupal:file
- drupal:layout_builder
+container_rebuild_required: false
diff --git a/core/modules/node/node.info.yml b/core/modules/node/node.info.yml
index 0b84728a00f..a08c08c15d1 100644
--- a/core/modules/node/node.info.yml
+++ b/core/modules/node/node.info.yml
@@ -6,3 +6,4 @@ version: VERSION
configure: entity.node_type.collection
dependencies:
- drupal:text
+container_rebuild_required: false
diff --git a/core/modules/options/options.info.yml b/core/modules/options/options.info.yml
index 6c6827b5d75..e52c6c89e76 100644
--- a/core/modules/options/options.info.yml
+++ b/core/modules/options/options.info.yml
@@ -6,3 +6,4 @@ version: VERSION
dependencies:
- drupal:field
- drupal:text
+container_rebuild_required: false
diff --git a/core/modules/package_manager/package_manager.info.yml b/core/modules/package_manager/package_manager.info.yml
index 20cd7bca565..104eaac3aff 100644
--- a/core/modules/package_manager/package_manager.info.yml
+++ b/core/modules/package_manager/package_manager.info.yml
@@ -4,6 +4,7 @@ description: 'API module providing functionality to stage package installs and u
package: Core
version: VERSION
lifecycle: experimental
+container_rebuild_required: false
dependencies:
- drupal:update
hidden: true
diff --git a/core/modules/page_cache/page_cache.info.yml b/core/modules/page_cache/page_cache.info.yml
index 010a7460c92..88308f48a4e 100644
--- a/core/modules/page_cache/page_cache.info.yml
+++ b/core/modules/page_cache/page_cache.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Caches pages for anonymous users and can be used when external page cache is not available.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/path/path.info.yml b/core/modules/path/path.info.yml
index 6b81d07ed64..f79c37654a9 100644
--- a/core/modules/path/path.info.yml
+++ b/core/modules/path/path.info.yml
@@ -6,3 +6,4 @@ version: VERSION
configure: entity.path_alias.collection
dependencies:
- drupal:path_alias
+container_rebuild_required: false
diff --git a/core/modules/path_alias/path_alias.info.yml b/core/modules/path_alias/path_alias.info.yml
index 76bdd35a48e..252d807ae5c 100644
--- a/core/modules/path_alias/path_alias.info.yml
+++ b/core/modules/path_alias/path_alias.info.yml
@@ -5,3 +5,4 @@ package: Core
version: VERSION
required: true
hidden: true
+container_rebuild_required: false
diff --git a/core/modules/pgsql/pgsql.info.yml b/core/modules/pgsql/pgsql.info.yml
index d2f23bd6f66..14dcea4a964 100644
--- a/core/modules/pgsql/pgsql.info.yml
+++ b/core/modules/pgsql/pgsql.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides the PostgreSQL database driver.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/phpass/phpass.info.yml b/core/modules/phpass/phpass.info.yml
index 63b61500211..beb46d5c873 100644
--- a/core/modules/phpass/phpass.info.yml
+++ b/core/modules/phpass/phpass.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides the password checking algorithm for user accounts created with Drupal prior to version 10.1.0.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/responsive_image/responsive_image.info.yml b/core/modules/responsive_image/responsive_image.info.yml
index 4c4e2f173d4..4400a080e64 100644
--- a/core/modules/responsive_image/responsive_image.info.yml
+++ b/core/modules/responsive_image/responsive_image.info.yml
@@ -7,3 +7,4 @@ dependencies:
- drupal:breakpoint
- drupal:image
configure: entity.responsive_image_style.collection
+container_rebuild_required: false
diff --git a/core/modules/rest/rest.info.yml b/core/modules/rest/rest.info.yml
index 8fe98a6ba97..bb807af6f59 100644
--- a/core/modules/rest/rest.info.yml
+++ b/core/modules/rest/rest.info.yml
@@ -5,3 +5,4 @@ package: Web services
version: VERSION
dependencies:
- drupal:serialization
+container_rebuild_required: false
diff --git a/core/modules/sdc/sdc.info.yml b/core/modules/sdc/sdc.info.yml
index d77086636a4..094728024c8 100644
--- a/core/modules/sdc/sdc.info.yml
+++ b/core/modules/sdc/sdc.info.yml
@@ -8,3 +8,4 @@ lifecycle_link: https://www.drupal.org/node/3223395#s-sdc
dependencies:
- drupal:serialization
hidden: true
+container_rebuild_required: false
diff --git a/core/modules/search/search.info.yml b/core/modules/search/search.info.yml
index e93859b5980..0be4eafe6d5 100644
--- a/core/modules/search/search.info.yml
+++ b/core/modules/search/search.info.yml
@@ -4,3 +4,4 @@ description: 'Allows users to create search pages based on plugins provided by o
package: Core
version: VERSION
configure: entity.search_page.collection
+container_rebuild_required: false
diff --git a/core/modules/serialization/serialization.info.yml b/core/modules/serialization/serialization.info.yml
index c8487553eeb..b768eb9b523 100644
--- a/core/modules/serialization/serialization.info.yml
+++ b/core/modules/serialization/serialization.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides a service for converting data to and from formats such as JSON and XML.'
package: Web services
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/settings_tray/settings_tray.info.yml b/core/modules/settings_tray/settings_tray.info.yml
index 13f9a152dcd..80dae441edb 100644
--- a/core/modules/settings_tray/settings_tray.info.yml
+++ b/core/modules/settings_tray/settings_tray.info.yml
@@ -7,3 +7,4 @@ dependencies:
- drupal:block
- drupal:toolbar
- drupal:contextual
+container_rebuild_required: false
diff --git a/core/modules/shortcut/shortcut.info.yml b/core/modules/shortcut/shortcut.info.yml
index 442eb09a80a..13450dd194d 100644
--- a/core/modules/shortcut/shortcut.info.yml
+++ b/core/modules/shortcut/shortcut.info.yml
@@ -6,3 +6,4 @@ version: VERSION
configure: entity.shortcut_set.collection
dependencies:
- drupal:link
+container_rebuild_required: false
diff --git a/core/modules/sqlite/sqlite.info.yml b/core/modules/sqlite/sqlite.info.yml
index 5d3a577dcf1..602b7f9709c 100644
--- a/core/modules/sqlite/sqlite.info.yml
+++ b/core/modules/sqlite/sqlite.info.yml
@@ -3,3 +3,4 @@ type: module
description: 'Provides the SQLite database driver.'
package: Core
version: VERSION
+container_rebuild_required: false
diff --git a/core/modules/syslog/syslog.info.yml b/core/modules/syslog/syslog.info.yml
index bb5f9ad21e5..de53550c0b0 100644
--- a/core/modules/syslog/syslog.info.yml
+++ b/core/modules/syslog/syslog.info.yml
@@ -4,3 +4,4 @@ description: "Logs events to the web server's system log."
package: Core
version: VERSION
configure: system.logging_settings
+container_rebuild_required: false
diff --git a/core/modules/system/system.info.yml b/core/modules/system/system.info.yml
index 546607028cf..16117d2e026 100644
--- a/core/modules/system/system.info.yml
+++ b/core/modules/system/system.info.yml
@@ -4,4 +4,5 @@ description: 'Provides user interfaces for core systems.'
package: Core
version: VERSION
required: true
+container_rebuild_required: false
configure: system.admin_config_system
diff --git a/core/modules/system/tests/modules/container_rebuild_required_dependency_false/container_rebuild_required_dependency_false.info.yml b/core/modules/system/tests/modules/container_rebuild_required_dependency_false/container_rebuild_required_dependency_false.info.yml
new file mode 100644
index 00000000000..8ca95925b81
--- /dev/null
+++ b/core/modules/system/tests/modules/container_rebuild_required_dependency_false/container_rebuild_required_dependency_false.info.yml
@@ -0,0 +1,8 @@
+name: 'Container rebuild required false'
+type: module
+description: 'Support module for ModuleInstaller testing.'
+container_rebuild_required: false
+dependencies:
+ - drupal:container_rebuild_required_true
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/container_rebuild_required_false/container_rebuild_required_false.info.yml b/core/modules/system/tests/modules/container_rebuild_required_false/container_rebuild_required_false.info.yml
new file mode 100644
index 00000000000..d1a3af62186
--- /dev/null
+++ b/core/modules/system/tests/modules/container_rebuild_required_false/container_rebuild_required_false.info.yml
@@ -0,0 +1,6 @@
+name: 'Container rebuild required false'
+type: module
+description: 'Support module for ModuleInstaller testing.'
+container_rebuild_required: false
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/container_rebuild_required_false_2/container_rebuild_required_false_2.info.yml b/core/modules/system/tests/modules/container_rebuild_required_false_2/container_rebuild_required_false_2.info.yml
new file mode 100644
index 00000000000..21fad05d806
--- /dev/null
+++ b/core/modules/system/tests/modules/container_rebuild_required_false_2/container_rebuild_required_false_2.info.yml
@@ -0,0 +1,6 @@
+name: 'Container rebuild required false 2'
+type: module
+description: 'Support module for ModuleInstaller testing.'
+container_rebuild_required: false
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/container_rebuild_required_true/container_rebuild_required_true.info.yml b/core/modules/system/tests/modules/container_rebuild_required_true/container_rebuild_required_true.info.yml
new file mode 100644
index 00000000000..22d7dced9ef
--- /dev/null
+++ b/core/modules/system/tests/modules/container_rebuild_required_true/container_rebuild_required_true.info.yml
@@ -0,0 +1,6 @@
+name: 'Container rebuild required true'
+type: module
+description: 'Support module for ModuleInstaller testing.'
+container_rebuild_required: true
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/container_rebuild_required_true_2/container_rebuild_required_true_2.info.yml b/core/modules/system/tests/modules/container_rebuild_required_true_2/container_rebuild_required_true_2.info.yml
new file mode 100644
index 00000000000..cca621d079c
--- /dev/null
+++ b/core/modules/system/tests/modules/container_rebuild_required_true_2/container_rebuild_required_true_2.info.yml
@@ -0,0 +1,6 @@
+name: 'Container rebuild required true 2'
+type: module
+description: 'Support module for ModuleInstaller testing.'
+container_rebuild_required: true
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/module_test/src/ModuleTestCompilerPass.php b/core/modules/system/tests/modules/module_test/src/ModuleTestCompilerPass.php
new file mode 100644
index 00000000000..95eb5288982
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test/src/ModuleTestCompilerPass.php
@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\module_test;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+
+/**
+ * Counts the number of times this compiler pass runs.
+ */
+class ModuleTestCompilerPass implements CompilerPassInterface {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function process(ContainerBuilder $container): void {
+ if (!isset($GLOBALS['container_rebuilt'])) {
+ $GLOBALS['container_rebuilt'] = 1;
+ }
+ else {
+ $GLOBALS['container_rebuilt']++;
+ }
+ }
+
+}
diff --git a/core/modules/system/tests/modules/module_test/src/ModuleTestServiceProvider.php b/core/modules/system/tests/modules/module_test/src/ModuleTestServiceProvider.php
new file mode 100644
index 00000000000..8987630f3d4
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test/src/ModuleTestServiceProvider.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\module_test;
+
+use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\DependencyInjection\ServiceProviderInterface;
+
+/**
+ * Module test service provider.
+ */
+class ModuleTestServiceProvider implements ServiceProviderInterface {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function register(ContainerBuilder $container): void {
+ $container->addCompilerPass(new ModuleTestCompilerPass());
+ }
+
+}
diff --git a/core/modules/system/tests/src/Functional/Pager/PagerTest.php b/core/modules/system/tests/src/Functional/Pager/PagerTest.php
index afe949acc4a..3f46565d049 100644
--- a/core/modules/system/tests/src/Functional/Pager/PagerTest.php
+++ b/core/modules/system/tests/src/Functional/Pager/PagerTest.php
@@ -42,6 +42,9 @@ class PagerTest extends BrowserTestBase {
protected function setUp(): void {
parent::setUp();
+ // Start from a clean log.
+ \Drupal::database()->delete('watchdog')->execute();
+
// Insert 300 log messages.
$logger = $this->container->get('logger.factory')->get('pager_test');
for ($i = 0; $i < 300; $i++) {
diff --git a/core/modules/taxonomy/taxonomy.info.yml b/core/modules/taxonomy/taxonomy.info.yml
index 2f95462f63e..c684b367a60 100644
--- a/core/modules/taxonomy/taxonomy.info.yml
+++ b/core/modules/taxonomy/taxonomy.info.yml
@@ -7,3 +7,4 @@ dependencies:
- drupal:node
- drupal:text
configure: entity.taxonomy_vocabulary.collection
+container_rebuild_required: false
diff --git a/core/modules/telephone/telephone.info.yml b/core/modules/telephone/telephone.info.yml
index 74b78da21b6..e9c483d6288 100644
--- a/core/modules/telephone/telephone.info.yml
+++ b/core/modules/telephone/telephone.info.yml
@@ -5,3 +5,4 @@ package: Field types
version: VERSION
dependencies:
- drupal:field
+container_rebuild_required: false
diff --git a/core/modules/text/text.info.yml b/core/modules/text/text.info.yml
index 67d3e86f625..8cc717484ee 100644
--- a/core/modules/text/text.info.yml
+++ b/core/modules/text/text.info.yml
@@ -6,3 +6,4 @@ version: VERSION
dependencies:
- drupal:field
- drupal:filter
+container_rebuild_required: false
diff --git a/core/modules/toolbar/toolbar.info.yml b/core/modules/toolbar/toolbar.info.yml
index e4b28753ae7..64da3651258 100644
--- a/core/modules/toolbar/toolbar.info.yml
+++ b/core/modules/toolbar/toolbar.info.yml
@@ -5,3 +5,4 @@ package: Core
version: VERSION
dependencies:
- drupal:breakpoint
+container_rebuild_required: false
diff --git a/core/modules/update/update.info.yml b/core/modules/update/update.info.yml
index 684c544b39e..feeb276de32 100644
--- a/core/modules/update/update.info.yml
+++ b/core/modules/update/update.info.yml
@@ -4,3 +4,4 @@ description: 'Checks for updates and allows users to manage them through a user
version: VERSION
package: Core
configure: update.settings
+container_rebuild_required: false
diff --git a/core/modules/user/user.info.yml b/core/modules/user/user.info.yml
index e30a8d56794..98e9f741df7 100644
--- a/core/modules/user/user.info.yml
+++ b/core/modules/user/user.info.yml
@@ -7,3 +7,4 @@ required: true
configure: user.admin_index
dependencies:
- drupal:system
+container_rebuild_required: false
diff --git a/core/modules/views/views.info.yml b/core/modules/views/views.info.yml
index eb07d856b2e..6c2643b6be0 100644
--- a/core/modules/views/views.info.yml
+++ b/core/modules/views/views.info.yml
@@ -3,5 +3,6 @@ type: module
description: 'Provides a framework to fetch information from the database and to display it in different formats.'
package: Core
version: VERSION
+container_rebuild_required: false
dependencies:
- drupal:filter
diff --git a/core/modules/views_ui/views_ui.info.yml b/core/modules/views_ui/views_ui.info.yml
index 7f56e03f310..0ba60f901a4 100644
--- a/core/modules/views_ui/views_ui.info.yml
+++ b/core/modules/views_ui/views_ui.info.yml
@@ -6,3 +6,4 @@ version: VERSION
configure: entity.view.collection
dependencies:
- drupal:views
+container_rebuild_required: false
diff --git a/core/modules/workflows/workflows.info.yml b/core/modules/workflows/workflows.info.yml
index 9bf079d6cee..46411375a53 100644
--- a/core/modules/workflows/workflows.info.yml
+++ b/core/modules/workflows/workflows.info.yml
@@ -4,3 +4,4 @@ description: 'Provides an interface to create workflows with transitions between
version: VERSION
package: Core
configure: entity.workflow.collection
+container_rebuild_required: false
diff --git a/core/modules/workspaces/workspaces.info.yml b/core/modules/workspaces/workspaces.info.yml
index 42be3a17bb5..d22933470e3 100644
--- a/core/modules/workspaces/workspaces.info.yml
+++ b/core/modules/workspaces/workspaces.info.yml
@@ -5,3 +5,4 @@ version: VERSION
package: Core
dependencies:
- drupal:user
+container_rebuild_required: false
diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
index 80c832f82b0..8e29eae7dd5 100644
--- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
@@ -166,6 +166,44 @@ class ModuleInstallerTest extends KernelTestBase {
}
/**
+ * Tests container rebuilding due to the container_rebuild_required info key.
+ *
+ * @covers ::install
+ *
+ * @param array $modules
+ * The modules to install.
+ * @param int $count
+ * The number of times the container should have been rebuilt.
+ *
+ * @dataProvider containerRebuildRequiredProvider
+ */
+ public function testContainerRebuildRequired(array $modules, int $count): void {
+ $this->container->get('module_installer')->install(['module_test']);
+ $GLOBALS['container_rebuilt'] = 0;
+ $this->container->get('module_installer')->install($modules);
+ $this->assertSame($count, $GLOBALS['container_rebuilt']);
+ }
+
+ /**
+ * Data provider for ::testContainerRebuildRequired().
+ */
+ public static function containerRebuildRequiredProvider(): array {
+ return [
+ [['container_rebuild_required_true'], 1],
+ [['container_rebuild_required_false'], 1],
+ [['container_rebuild_required_false', 'container_rebuild_required_false_2'], 1],
+ [['container_rebuild_required_false', 'container_rebuild_required_false_2', 'container_rebuild_required_true'], 1],
+ [['container_rebuild_required_false', 'container_rebuild_required_false_2', 'container_rebuild_required_true', 'container_rebuild_required_true_2'], 2],
+ [['container_rebuild_required_true', 'container_rebuild_required_false', 'container_rebuild_required_false_2'], 2],
+ [['container_rebuild_required_false', 'container_rebuild_required_true', 'container_rebuild_required_false_2'], 2],
+ [['container_rebuild_required_false', 'container_rebuild_required_true', 'container_rebuild_required_false_2', 'container_rebuild_required_true_2'], 2],
+ [['container_rebuild_required_true', 'container_rebuild_required_false', 'container_rebuild_required_true_2', 'container_rebuild_required_false_2'], 3],
+ [['container_rebuild_required_false_2', 'container_rebuild_required_dependency_false'], 2],
+ [['container_rebuild_required_false_2', 'container_rebuild_required_dependency_false', 'container_rebuild_required_true'], 2],
+ ];
+ }
+
+ /**
* Tests trying to install a deprecated module.
*
* @covers ::install
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 94be1c7ddf7..8189b7320ae 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -571,6 +571,7 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
$this->keyValue = new KeyValueMemoryFactory();
}
$container->set('keyvalue', $this->keyValue);
+ $container->getDefinition('keyvalue')->setSynthetic(TRUE);
// Set the default language on the minimal container.
$container->setParameter('language.default_values', Language::$defaultValues);