diff --git a/core/assets/scaffold/files/example.settings.local.php b/core/assets/scaffold/files/example.settings.local.php index 4a40a1318b47d6be26f2e63f65ebec2cf5c935a7..520cb4acd5fabfa96578373a0dd07ef59e275a43 100644 --- a/core/assets/scaffold/files/example.settings.local.php +++ b/core/assets/scaffold/files/example.settings.local.php @@ -129,3 +129,27 @@ * directory. */ $settings['skip_permissions_hardening'] = TRUE; + +/** + * Exclude modules from configuration synchronisation. + * + * On config export sync, no config or dependent config of any excluded module + * is exported. On config import sync, any config of any installed excluded + * module is ignored. In the exported configuration, it will be as if the + * excluded module had never been installed. When syncing configuration, if an + * excluded module is already installed, it will not be uninstalled by the + * configuration synchronisation, and dependent configuration will remain + * intact. This affects only configuration synchronisation; single import and + * export of configuration are not affected. + * + * Drupal does not validate or sanity check the list of excluded modules. For + * instance, it is your own responsibility to never exclude required modules, + * because it would mean that the exported configuration can not be imported + * anymore. + * + * This is an advanced feature and using it means opting out of some of the + * guarantees the configuration synchronisation provides. It is not recommended + * to use this feature with modules that affect Drupal in a major way such as + * the language or field module. + */ +# $settings['config_exclude_modules'] = ['devel', 'stage_file_proxy']; diff --git a/core/core.services.yml b/core/core.services.yml index e7378c6abf116fa02aeb909b96319dffbc238114..091289c2d265c7471e7658733bf58da7b0efa13b 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1280,6 +1280,11 @@ services: tags: - { name: event_subscriber } arguments: ['@config.manager', '@config.storage', '@config.storage.snapshot'] + config_exclude_modules_subscriber: + class: Drupal\Core\EventSubscriber\ExcludedModulesEventSubscriber + arguments: ['@config.storage', '@settings', '@config.manager'] + tags: + - { name: event_subscriber } exception.needs_installer: class: Drupal\Core\EventSubscriber\ExceptionDetectNeedsInstallSubscriber arguments: ['@database'] diff --git a/core/modules/config_environment/src/EventSubscriber/ExcludedModulesEventSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExcludedModulesEventSubscriber.php similarity index 99% rename from core/modules/config_environment/src/EventSubscriber/ExcludedModulesEventSubscriber.php rename to core/lib/Drupal/Core/EventSubscriber/ExcludedModulesEventSubscriber.php index 90a81de16e7f87f15db8f5f21e58f11835cfdd72..a81f3e02a8cd449c5604724d44eafea95a93161b 100644 --- a/core/modules/config_environment/src/EventSubscriber/ExcludedModulesEventSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ExcludedModulesEventSubscriber.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\config_environment\EventSubscriber; +namespace Drupal\Core\EventSubscriber; use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Config\StorageInterface; diff --git a/core/modules/config_environment/tests/config_exclude_test/config/install/system.menu.exclude_test.yml b/core/modules/config/tests/config_exclude_test/config/install/system.menu.exclude_test.yml similarity index 100% rename from core/modules/config_environment/tests/config_exclude_test/config/install/system.menu.exclude_test.yml rename to core/modules/config/tests/config_exclude_test/config/install/system.menu.exclude_test.yml diff --git a/core/modules/config_environment/tests/config_exclude_test/config/install/system.menu.indirect_exclude_test.yml b/core/modules/config/tests/config_exclude_test/config/install/system.menu.indirect_exclude_test.yml similarity index 100% rename from core/modules/config_environment/tests/config_exclude_test/config/install/system.menu.indirect_exclude_test.yml rename to core/modules/config/tests/config_exclude_test/config/install/system.menu.indirect_exclude_test.yml diff --git a/core/modules/config_environment/tests/config_exclude_test/config_exclude_test.info.yml b/core/modules/config/tests/config_exclude_test/config_exclude_test.info.yml similarity index 59% rename from core/modules/config_environment/tests/config_exclude_test/config_exclude_test.info.yml rename to core/modules/config/tests/config_exclude_test/config_exclude_test.info.yml index 6ee30864798c95931763c041b06a2b2ae7d03e07..b84feef93aa34a9a96f275eff8dd9072cd5ce963 100644 --- a/core/modules/config_environment/tests/config_exclude_test/config_exclude_test.info.yml +++ b/core/modules/config/tests/config_exclude_test/config_exclude_test.info.yml @@ -1,4 +1,3 @@ -# @todo: Move this test module under the config module in #3079029. name: 'Configuration Module Exclude Test' type: module package: Testing diff --git a/core/modules/config_environment/config_environment.services.yml b/core/modules/config_environment/config_environment.services.yml deleted file mode 100644 index 857f3eda8c6da924fa2fa348fe206726830478ff..0000000000000000000000000000000000000000 --- a/core/modules/config_environment/config_environment.services.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - config_environment.excluded_modules.event_subscriber: - class: Drupal\config_environment\EventSubscriber\ExcludedModulesEventSubscriber - arguments: ['@config.storage', '@settings', '@config.manager'] - tags: - - { name: event_subscriber } diff --git a/core/modules/config_environment/tests/src/Kernel/EventSubscriber/ExcludedModulesEventSubscriberTest.php b/core/tests/Drupal/KernelTests/Core/Config/ExcludedModulesEventSubscriberTest.php similarity index 97% rename from core/modules/config_environment/tests/src/Kernel/EventSubscriber/ExcludedModulesEventSubscriberTest.php rename to core/tests/Drupal/KernelTests/Core/Config/ExcludedModulesEventSubscriberTest.php index 8e7f0638fc65de9eedf8dcf0474bc72d7e813a0c..10e73cee9606de78230bf669fa5f036846dde7a7 100644 --- a/core/modules/config_environment/tests/src/Kernel/EventSubscriber/ExcludedModulesEventSubscriberTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ExcludedModulesEventSubscriberTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\Tests\config_environment\Kernel\EventSubscriber; +namespace Drupal\KernelTests\Core\Config; use Drupal\KernelTests\KernelTestBase; @@ -16,7 +16,6 @@ class ExcludedModulesEventSubscriberTest extends KernelTestBase { */ protected static $modules = [ 'system', - 'config_environment', 'config_test', 'config_exclude_test', ]; diff --git a/sites/example.settings.local.php b/sites/example.settings.local.php index 4a40a1318b47d6be26f2e63f65ebec2cf5c935a7..520cb4acd5fabfa96578373a0dd07ef59e275a43 100644 --- a/sites/example.settings.local.php +++ b/sites/example.settings.local.php @@ -129,3 +129,27 @@ * directory. */ $settings['skip_permissions_hardening'] = TRUE; + +/** + * Exclude modules from configuration synchronisation. + * + * On config export sync, no config or dependent config of any excluded module + * is exported. On config import sync, any config of any installed excluded + * module is ignored. In the exported configuration, it will be as if the + * excluded module had never been installed. When syncing configuration, if an + * excluded module is already installed, it will not be uninstalled by the + * configuration synchronisation, and dependent configuration will remain + * intact. This affects only configuration synchronisation; single import and + * export of configuration are not affected. + * + * Drupal does not validate or sanity check the list of excluded modules. For + * instance, it is your own responsibility to never exclude required modules, + * because it would mean that the exported configuration can not be imported + * anymore. + * + * This is an advanced feature and using it means opting out of some of the + * guarantees the configuration synchronisation provides. It is not recommended + * to use this feature with modules that affect Drupal in a major way such as + * the language or field module. + */ +# $settings['config_exclude_modules'] = ['devel', 'stage_file_proxy'];