5

Drupal 8.8 introduced a new setting: https://www.drupal.org/node/3079028

By adding these lines to your settings.local.php I expected the modules and their configuration to be excluded from config export.

$settings['config_exclude_modules'] = ['kint', 'devel'];

However:

  • kint and devel still appear in my core.extensions.yml
  • Yaml files related to devel still get generated.
  • Modules are still removed and installed based on the core.extensions.yml

How does this feature work?

Edit: I upgraded from Drupal 8.7, that seems to keep this function to work properly.

6
  • 3
    Does this answer your question? How to prevent Devel module to be installed on production environments
    – leymannx
    Commented Mar 3, 2020 at 10:51
  • 3
    I'd recommend Configuration Split. See drupal.stackexchange.com/a/264358/15055 how.
    – leymannx
    Commented Mar 3, 2020 at 10:53
  • 3
    I know about configuration split, but I want to know how this feature works, because it is in drupal core. Now it seems to do nothing. Maybe I do something wrong. drush cex --skip-modules seems not to do anything either. Maybe it is removed from drush 9. Commented Mar 3, 2020 at 14:21
  • 1
    Stupid question: Did you ensure your settings.local.php gets included correctly from settings.php in all environments?
    – leymannx
    Commented Mar 3, 2020 at 14:32
  • 1
    I created a drush script with this line of code: dump(Drupal::service('settings')->get('config_exclude_modules')); It shows that the content of this setting is as expected. Commented Mar 3, 2020 at 21:39

2 Answers 2

4

Enable the module and activate the filter by declaring $settings['config_exclude_modules'] in your settings.php file, eg:

$settings['config_exclude_modules'] = ['devel', 'stage_file_proxy'];

Now, when you export configuration (drush config-export), the selected modules should no longer show up in core.extension.yml and their configuration should not be exported.

Make sure first before doing that to remove these module from core.extensions.yml manually for the first time.

Update: It seems to be related to a drush issues: drush config:status does not respect excluded modules #4194

3
  • 2
    When I do so, after I do drush config-export it overwrites core.extensions.yml. When I remove them and do drush config-import it uninstalls the devel and stage_file_proxy module. Commented Mar 12, 2020 at 9:38
  • 1
    It works as expected for fresh installations of Drupal 8.8 Commented Mar 12, 2020 at 20:30
  • 1
    It did not work out well for my upgraded 8.7 to 8.8 install, but it makes sense to first remove the yml files. Else errors show you the way to what yaml files you should remove to make it work. Commented Mar 16, 2020 at 11:49
0

Addendum really, as I was looking at the logic in ExcludedModulesEventSubscriber that does most of the work for config_exclude_modules.

Say module foo has some config in config/install, and you exclude module foo and then install the module. The config that is installed from config/install will not necessarily be excluded by config_exclude_modules in the future.

For config to be excluded needs to belong to the module by name (foo.*) or there should be a dependency on the module in the config.

For example, say if your module foo installs a view that you would like to also be excluded config, then it will be excluded based on the dependencies of that view.

dependencies:
  module:
    - node
    - etc

However you can add an enforced dependency to prevent this.

dependencies:
  module:
    - node
    - etc
  enforced:
    module:
      - foo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.