Enforced config dependencies override normal dependencies instead of adding to them

Created on 24 August 2018, about 6 years ago
Updated 6 June 2023, over 1 year ago

Problem/Motivation

Marking this as major because any wrongly missing config dependencies can put the system into a broken state.

\Drupal\Core\Config\ConfigInstaller::getMissingDependencies() adds the enforced dependencies to the normal dependencies with the following code (line 571):

$all_dependencies = array_merge($all_dependencies, $data['dependencies']['enforced']);

(Let's ignore the fact that it weirdly uses $data['dependencies']['enforced'] instead of $all_dependencies['enforced'] for the time being.)

But both data structures are nested arrays, of the form:

[
  'module' => [ ... ],
  'theme' => [ ... ],
  'config' => [ ... ],
];

Because array_merge() is used, and not array_merge_recursive(), if, for example, $data['dependencies']['enforced'] contains a 'module' key, the list of enforced modules will replace the list of modules that are in $all_dependencies['module'] (if any), instead of adding to it.

Proposed resolution

  1. Write a failing test that proves the bug.
  2. Replace array_merge() with array_merge_recursive() in the offending line to fix the test and the bug.

Note that all of the lists of dependencies are integer-keyed, so that we can safely use array_merge_recursive()
and do not need NestedArray::mergeDeep().

πŸ› Bug report
Status

Closed: duplicate

Version

9.5

Component
Configuration entityΒ  β†’

Last updated 2 days ago

Created by

πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

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

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