\Drupal\config_update\ConfigReverter::getFromExtension may return wrong data

Created on 18 September 2023, over 1 year ago
Updated 19 September 2023, over 1 year ago

Problem/Motivation

If there is a module that overrides a config entity of another module, e.g. overriding the view configuration of watchdog, and you want to revert the config to that ion the overriding module, that may fail when \Drupal\Core\Config\StorageInterface::read happens to return the config from the original config. This seems to be random, or maybe driven by module sorting (weight and alphabetical) in core.

Steps to reproduce

Create a module and copy views.view.user_admin_people from the user module into that new module. Then make some changes to that copied view and update the config in that new module. Now, the config in the new module and on the Drupal site are the same. But when you run drush config:different-report module newmodule, the output indicates, that the view has changed. And when you run drush config:revert-multiple module newmodule, it will revert to the original view config from the user module.

Proposed resolution

The method \Drupal\config_update\ConfigReverter::getFromExtension should not use \Drupal\Core\Config\StorageInterface::read to read the extension config. Instead, it should read from the file system explicitly from the given module.

🐛 Bug report
Status

Active

Version

2.0

Component

Drush commands

Created by

🇩🇪Germany jurgenhaas Gottmadingen

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

Comments & Activities

  • Issue created by @jurgenhaas
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Oh dear, just realizing that this issue is not only present when comparing config entities to create the diff report, this is all over the place. Of course, this could be replaced everywhere in a similar way, but the issue is that we would have to forward the type and name of the extension as well, so that we can read the correct file from the extension. That would be a major change. I'm surprised that this hasn't been recognized before.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    As a workaround in our situation, I've now added a command to raise the weight of the module to 999 before calling any of the Drush commands. This is working fine, since modules with a higher weight always override those with lower weights.

    Changing the component to Drush, but the same happens as well in the UI, but there a refactoring would be required to get this addressed.

Production build 0.71.5 2024