Fix module config with drupal/core-composer-scaffold

Scenario:
You install a contrib module that supplies configuration via config/install, but the configuration does not match with your system setup. This may result in a ugly (though not breaking) error during installation of your project. You can repair this later on by importing the correct config (for example via drush cim --partial), but the error during installation of the project will persist.

Example:
The modules provides a search api index config with a field that does not exist in your setup. Then the installer is complaining with something like
Could not retrieve data definition for field ... on index ...

Solution:
You can use drupal/core-composer-scaffold for this to replace the config in the modules directory with the config that matches your setup.

Example in composer.json "extra" part:

"extra": {
  "drupal-scaffold": {
    ..
    "file-mapping": {
    ..
      "[web-root]/modules/contrib/dkan/modules/metastore/modules/metastore_search/config/install/search_api.index.dkan.yml": "config/repair-search/search_api.index.dkan.yml"
    ..
    }
  ..
  }
..
}

This will replace the config after the module is installed via composer, thus having the correct configuration in place when you install.

One could also patch the module to solve this, but this workaround might be easier if you already have the valid configuration somewhere in your code. And it will stay in line with this configuration as you change it, while a patch would not.

Neuen Kommentar schreiben

Filtered HTML

  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.

Plain text

  • Keine HTML-Tags erlaubt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.