Config export key order is not predictable, use config schema to order keys for maps

Created on 14 February 2017, almost 8 years ago
Updated 28 April 2023, over 1 year ago

Problem/Motivation

Follow-up to #2361539: Config export key order is not predictable for sequences, add orderby property to config schema

As shown in #2350821: Sort views displays by display name and #2350537: Enforce order of display of components in config export shows that even though #2256679: Use config schema to determine which config entity properties to export regardless of whether they are public or protected made use of config schema to export the top level keys, for lower levels we still rely on the data provided as-is. That means that if keys are reordered for some reason, there will be unnecessary diffs. We should sorting maps in the same way order that the mapping is defined in the schema.

In the absence of a solution in core, various approaches have sprung up in contrib aimed at normalizing config for purposes of comparison or merging. These include:

Proposed resolution

Use the order defined in a config schema data types mapping to sort the result configuration array. This makes the entire system work the same was as #2256679: Use config schema to determine which config entity properties to export regardless of whether they are public or protected .

Remaining tasks

Agree. Do it.

User interface changes

None.

API changes

None?

Data model changes

Some configuration re-ordered.

Release notes snippet

Config is sorted by the order defined in its schema. You should always re-export configuration and commit it to version control after running updates. See the change record for more recommendations.

📌 Task
Status

Fixed

Version

9.3

Component
Configuration 

Last updated 1 day ago

Created by

🇬🇧United Kingdom alexpott 🇪🇺🌍

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.

  • 🇪🇸Spain Carlitus

    I think something related still happens to us in our projects.

    After a Drupal or module update, it happens very often that when I do a cex I see a lot of changes. But they are not changes that we have actually made. For example, changes of the position in the yml.

    Example screenshot:

Production build 0.71.5 2024