Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Drupal 8 Config Readonly module's "whitelist" functionality

Parent Feed: 

I've been a big fan of Drupal 8's configuration system since the beta-days of Drupal 8, and even more so now as the contributed module ecosystem around it has matured. I've been using the Config Readonly module from the very beginning to "lock down" configuration on production environments in order to help enforce developer workflows. 

Using the Config Readonly module is a bit of a double-edged sword. On one hand, it really helps in helping get developers accustomed to making configuration changes on local, then exporting them using Drupal 8's configuration system, committing them to the repository, and then moving them up through the project's defined deployment workflow.

On the other hand, sometimes it just really gets in the way. Two areas where I find that clients really find Config Readonly annoying in the live environment is when configuring menu items and block placement, both which can be affected by locked-down configuration. When the Config Readonly module is active, it is not possible to drag-and-drop menu links to reorder them. Nor is it possible to place a block or move a block to a new location.  

Luckily, the Config Readonly module maintainers added the ability to "whitelist" some configurations in version 8.x-1.0-beta3. This allows developers to keep certain configurations "unlocked" on the live environment via the settings.php file. For example:

if (IS_LIVE_ENVIRONMENT) {
  $settings['config_readonly'] = TRUE;
  $settings['config_readonly_whitelist_patterns'] = [
    'page_manager.page_variant.*',
    'system.menu.main',
  ];
}

In this code snippet, all Panel page variant configuration as well as the main menu are whitelisted, allowing site authors to modify these aspects of the site directly on the live environment.

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web