Update Config Enforce Devel hooks to work with latest Config Devel issue fork

Created on 3 March 2023, over 1 year ago
Updated 6 April 2023, about 1 year ago

Problem/Motivation

✨ Define hooks to provide 'auto_import' and 'auto_export' Needs review is now pending review with a bunch of tests. It's unclear how long it'll take because the maintainers seem busy with other stuff and have not responded at time of writing.

The following is left as-is but is no longer relevent as this has been fixed/accommodated in the issue merge request above:

Now that work on ✨ Define hooks to provide 'auto_import' and 'auto_export' Needs review has finally moved forward, the format that Config Enforce Devel provides config files to the new Config Devel auto import hook is having unexpected fatal errors. These seem to be caused by Config Enforce Devel's hook returning an array with config names as keys, while Config Devel saves auto import as a sequence, i.e. not a map but a numerically indexed array. Why is this significant? Because the updated/refactored Config Devel auto import hook now passes what we return to Drupal's configuration system, which in turn interprets the dot separator (.) in the key name as a multi-level config, which is then saved as a nested array when in fact Config Devel expects it to be a flat sequence. To illustrate:

[
  'enforced.config.item' => [
    'filename'  => '...',
    'hash'      => '...',
  ],
]

gets parsed and saved to config storage as:

[
  'enforced' => [
    'config' => [
      'item' => [
        'filename'  => '...',
        'hash'      => '...',
      ],
    ],
  ],
]

which which ends up causing fatal errors.

Steps to reproduce

Check out latest Config Devel from ✨ Define hooks to provide 'auto_import' and 'auto_export' Needs review and current dev Config Enforce Devel. Try to add some enforced config. Behold, a wild white screen of death appears.

Proposed resolution

While we wait for the maintainers to review and eventually merge the updated hooks, we can update our implementation of the hooks and along with updatin the patch for Config Devel. Once the hooks issue is merged, we can then remove the patch.

Outdated stuff follows:

Part of the fix should be to contribute an \array_values() around the return value of the hooks and/or some better error checking in Config Devel so that it doesn't save a badly structured array. A test should also be contributed to ensure it can deal with malformed hook return values and keep on functioning.

That only solves part of the problem, because Config Enforce Devel depends on the string array keys to identify config, so that will have to be modified.

Remaining tasks

Update our code to work with the updated import hooks.

User interface changes

None.

API changes

None?

Data model changes

Probably none? Unsure.

πŸ“Œ Task
Status

Postponed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Ambient.Impact Toronto

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

Comments & Activities

Production build 0.69.0 2024