Impossible to config override a key's value to an empty array

Created on 3 August 2018, over 6 years ago
Updated 6 October 2023, about 1 year ago

Problem/Motivation

Suppose your live website has been configured to send security notifications to an email address, but you don't want to receive these notifications from your internal dev/test servers.

I thought I could do something like this in settings.php:

$config['update.settings']['notification']['emails'] = [];

However, that does not actually override this configuration variable. I tested with "drush config-get update.settings notification.emails --include-overridden", but I still see my original value.

Yet, if I override the config variable to a non-empty array, it works fine.

$config['update.settings']['notification']['emails'] = ['some-bogus-email@example.com'];

Why can I not set the override to an empty array?

Proposed resolution

Overrides may return an EmptyIterator() as value to indicate their desire to empty the existing array. See the test in the MR for an example, or see Domain Perm contrib module which dynamically neuters permissions in a role.

Remaining tasks

Update https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-... once released.

User interface changes

None

API changes

None - fully backward compatible.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Configuration 

Last updated 2 days ago

Created by

🇺🇸United States joelstein

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024