Module does not import configuration collections.

Created on 26 April 2025, 2 months ago

Problem/Motivation

When there are configurations inside a collection, the module does not import them correctly.

Steps to reproduce

1. Create a module with a configuration collection structure:

my_module/
  config/
    config1.yml
    language/
      es/
        config1.yml

2. Add an update hook to import configuration:

function my_module_update_11101() {
  \Drupal::service('devutils.update_import')
    ->import('my_module', [
      'config1',
    ]);
}

3. Run the update.

Expected:
Both config1.yml and language/es/config1.yml should be imported.

Actual:
Only config1.yml is imported; the language.es collection is ignored.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡ΊCuba ReyRPB

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ReyRPB
  • πŸ‡¨πŸ‡ΊCuba jleon1110

    The problem is that in the hook used, only one file, config1.yml, is being imported, and the configuration directory is not being scanned recursively.

    <?php
    function my_module_update_11101() {
      \Drupal::service('devutils.update_import')
        ->import('my_module', [
          'config1',
          'language.es.config1',
        ]);
    }
    ?>

    With this configuration, it should be possible to import exclusively both files. If there are more directories or folders, I recommend using web/core/lib/Drupal/Core/Config/ConfigInstaller.php as a base to import the configurations.

  • πŸ‡ΊπŸ‡ΎUruguay ruby232 Montevideo

    I think it's better to automatically add the language collection and only import it if the corresponding configuration files exist.

Production build 0.71.5 2024