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
, notvalue
. 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