Skip to main content
Image
1920x600-14.jpg

How does Drupal Configuration Update Module Work

article publisher

Raman

Drupal

When a module is updated, it may add new or change existing configurations items. To track, export, import and revert back from these changes in configuration items, Configuration Update module can be used.

Note that it is not recommended to change any configurations on a live site.

Configuration files in Drupal are used to store information such as basic site settings, block layouts, permissions, content types, taxonomy vocabularies, etc. These configuration files are stored as YAML files, where data is stored in key-value pairs. Drush can be used to view all the configuration files in a Drupal site:

$ drush config-list
or
$ drush cli 

You update a module, and it has either changed default config that it provides, or added new config items. You want to be able to import the new items, view the differences between the site config and the changed config, and possibly "revert" (or it may be an update) to the newly-provided default config.” - Drupal.org

Configuration files can be classified as - active and staging. The active configuration files are the currently imported configurations and are stored in the config table in the database. Whenever a module or theme is installed, its configuration files are imported into the active configuration of the site. The default configurations of any module are placed inside its config/install directory. The Configuration Update works by comparing the default configurations with the active configuration of the site.

Configuration Update project consists of two modules - Configuration Update Base and Configuration Update Reports. The former is a base module that computes the differences between configurations and the latter one provides the UI to generate reports.

Prerequisites

Configuration Update Base Module requires Configuration Manager module, which comes with Drupal core and Configuration Update Reports requires Configuration Update Base to be enabled.

Downloading and Installing Configuration Update Module
Configuration Update module can be downloaded and  installed using any of the following methods:

Using UI

  1. Navigate to Manage → Extend → Install new module and enter the .tar.gz or .zip URL of the Configuration Update module and hit Install
    Installing configuration update using FTP
    Installing configuration update using FTP
  2. Once the downloader and installer are finished downloading, click on “Enable newly added modules”.
     
  3. Find Configuration Update Base and Configuration Update Reports in the list of modules, select it and click on Install.

For rest of the methods, first, navigate to the root directory of your Drupal site,

$ cd /var/www/html/drupal-8.4.4

Using Composer

  • Add Configuration Update package using composer

$ composer require "drupal/config_update"

  • Enable Configuration Update Base and Configuration Update Reports modules by navigating to Manage → Extend, selecting them and click Install

Using Drush

  • Download and enable Configuration Update using Drush

$ drush dl config_update
$ drush en config_update config_update_ui

Using Drupal Console

  • Download and install Configuration Update using Drupal Console

$ drupal module:download config_update
$ drupal module:install config_update config_update_ui

Generating Reports with Configuration Update Reports

The reports show the differences the active configuration of your Drupal site and the default configuration provided by the themes, modules and installer profiles. These reports can be generated using Drush as well as using UI.

Navigate to Manage → Configuration → Development → Configuration synchronization → Update report tab

You will be presented with the following types of reports that can be generated:

  • Full Report: Lists all the configuration files of your Drupal site.
     
  • Single configuration type: Lists the configuration files of a specific configuration object such as Action, Block, View, etc.
     
  • Single module: Lists the configuration files of a specific module like Devel, Pathauto, Redirect, etc.
     
  • Single theme: Lists the configuration files of a specific theme like Bartik, Integrity, Mayo, etc.
     
  • Installation profile: Lists the configuration files of an installer profile like Basic, Standard or a custom installer profile.
types of reports generated using Config Update Reports
Types of reports generated using Config Update Reports

Click the “Everything” button to generate the complete list of configuration items of all types. One thing to observe is that the reports are categorized into three sections:

  • Missing configuration items: 

Shows the configuration items missing from the active configuration of the Drupal site that is provided by the modules, themes or installer profiles. These items can be imported using drush or UI.

$ drush config-missing-report <type> <name>
or
$ drush crm <type> <name>

Example:  $ drush config-added-report block block.block.integrity.help 

  • Added configuration items:

These usually include the items added or modified during site-building and are not provided by the modules, themes or installer profiles.

$ drush config-added-report <name>
or
$ drush cra <name>

Example:  $ drush config-added-report system.all

  • Changed configuration items:

These are the items that are currently in the active configuration of the site and differ from the default configuration provided by modules, themes or installer profiles. Note that the installer profiles can override the settings of a module in the differences widget as the module gives precedence to the installer profile version.

$ drush config-different-report  <type> <name>
or
$ drush crd  <type> <name>

Example: 

$ drush config-different-report image_style image.style.max_325x325

You can see differences, revert back to the default configuration provided by the module, theme or installer profile, or export them to view the YML file.

Importing an item from Source (default configuration)

Configuration files can be imported from the default configuration provided by the module, theme or installer profile into the active configuration of the site. This option is available only for missing or inactive optional configuration items.

Importing a configuration item from default configuration to active configuration using UI
Importing a configuration item from default configuration to active configuration using UI

 

  1. Click on the “Import from source” button against the configuration object to be imported.
     
  2. Confirm the import by clicking on “Import” from the page that appears.

Using Drush:

$ drush config-import-missing <name>
or
$ drush cfi <name>

Example: 

$ drush config-import-missing responsive_image.styles.narrow

Use drush config-diff <name> to view the differences between active and imported configuration.

Exporting an item from Source (default configuration)

Some configuration items may be added or changed during site-building. These can be exported as YML files. Click on the “Export” button to export the configuration item.

Exporting an added or modified configuration
Exporting an added or modified configuration

Reverting back to the default configuration

To revert back to the default configuration provided by the module, theme or installer profile, click on “Revert to source” option from the drop-down menu of the button against the configuration item. Then click on “Revert” button to confirm the operation.

Using Drush:

$ drush config-revert <name>
or
$ drush cfr <name>

Example: 

$ drush config-revert block.block.bartik_branding

To revert all the configuration items of a module, type, theme or installer profile use drush config-revert-multiple (cfrm)

$ drush config-revert-multiple <type> <name>

To Conclude

Configuration Update module allows easing the management of the configuration files of modules, themes and installer profiles through the generation of reports. It also provides the ability to export the added or modified configuration items, and to revert back to the default configuration - both using UI and drush commands.

Subscribe

Ready to start your digital transformation journey with us?

Related Blogs

SDC: Integrating Storybook & Single Directory Component

Integrating SDC With Storybook OpenSense Labs

Today, we will talk about about Drupal Single Directory Components or SDC and Storybook. Single Directory Components in Drupal allows you…

RFP: How To Create An RFP For Open Source Solutions?

RFP OpenSense Labs

A good Request for Proposals (RFP) or Call for Proposals (CFP) clearly states the goals and expectations of your project and sets the…

Drupal 7 End Of Life: Top Reasons You Should Migrate To Drupal 10

Drupal 7 End Of Life Cover Image OpenSense Labs

Drupal 10 was released in December 2022 and ever since, the community has been pushing its users to do Drupal 7 to 10 migration. As per…