Problem/Motivation

To ensure that dependencies for configurations added in configuration overrides are merged properly, we're not allowed to use numerical indices. Drupal uses NestedArray::mergeDeep to merge these arrays and this function will override any numerical indices. To get around this we use string keys which are properly preserved and allow to add to these arrays in multiple different places. This works without issues for simple keys and values, such as module names.

A problem arises when the dependency that's added contains dots and this value is used as key without modification. For example when the dependency is for another configuration object. The Drupal\Core\Config\Schema\ArrayElement class contains logic on how to traverse configuration (see get method). When a configuration name contains a dot then this method will interpret that as a nested path. However, for values in these dependencies arrays there are no nested values. This causes a fatal error InvalidArgumentException: "The configuration property $name doesn't exist.".

This was discovered in SocialGroupFlexibleGroupConfigOverride and a file search showed no other such issues. However, the issue may also be present in code outside of Open Social that follows a similar pattern.

Steps to reproduce

  1. Enable the social_group_flexible_group module
  2. Enable the config_inspector module
  3. Visit the config inspector report page at /admin/reports/config-inspector

Proposed resolution

Replace the dots in the key with underscores. This ensures that the key are still non-numeric and unique, which keeps the functionality for merging the overridden arrays. It also avoids providing a dot to the traversal logic in ArrayElement solving the issue.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Comments

Kingdutch created an issue. See original summary.

kingdutch’s picture

Assigned: kingdutch » Unassigned
Issue summary: View changes
Status: Active » Needs review
ronaldtebrake’s picture

Status: Needs review » Fixed

Will be in the next 9.x release

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.