Config export key order for sequences: "orderby" does not support cases where the order actually matters

Created on 12 June 2017, about 7 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

#2361539: Config export key order is not predictable for sequences, add orderby property to config schema β†’ introduced predictable sequence ordering. It introduced orderby: value and orderby: key. But quite a few things in core and contrib depend on "source order": where the stored order actually has meaning. This was overlooked. Therefore those cases are left with an unclear upgrade path.

Relevant comments lifted from #2361539, which is closed:

  • Wim Leers:

    Actually, there is an important question that is not answered by the CR or the IS, at least not AFAICT. Quoting #2874633-5: [PP-1] Update CDN module for Drupal 8.4.x: 'orderby' in config schema for sequences β†’ :

    +++ b/config/schema/cdn.mapping.schema.yml
    @@ -27,6 +27,7 @@ cdn.mapping.auto-balanced:
    +      orderby: value
    
    @@ -43,6 +44,7 @@ cdn.mapping.complex:
    +      orderby: value
    

    Actually, these should not be sorted/ordered… the order does matter in this case, and it cannot be ordered by key (there isn't any). In fact, the key is numerical, hence indicating the order already.

    So these should be key, not value. I think that that must be the general rule for non-associative arrays where the order matters?

    Reopening this issue to get an answer to that question documented in the CR, because more modules will struggle with that.

  • Alex Pott:

    @Wim Leers hmmm this is a good question. Actually in this instance the best practice is to have a weight key and sort by something that does not change. This means that if things are re-ordered when you review the config change the only thing you have to review is the weight key changes. However maybe we need to add "in the order added" type of "sort" so at least the current behaviour of cdn could be documented and we could document that this is bad practice and recommend ways of fixing it.

  • Wim Leers;

    However maybe we need to add "in the order added" type of "sort" so at least the current behaviour of cdn could be documented and we could document that this is bad practice and recommend ways of fixing it.

    +1 to both of those.

  • Wim Leers:

    By the way, an example of exactly the same problem/requirement can be found in ckeditor.schema.yml: the Toolbar configuration mapping contains a sequence of rows, which contains a sequence of buttons groups, which contains a sequence of buttons. None of them have "weight" or "priority"; the order is relevant there, too.

    So this is not a problem that's exclusive to contrib. And probably there are even more like these in other places in core.

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

None.

API changes

TBD

Data model changes

TBD

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
ConfigurationΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
  • Upgrade path

    It affects the ability to upgrade Drupal sites to a new major version. Preferred over version-specific tags such as D7 upgrade path.

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.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.69.0 2024