Problem/Motivation
I've ran into an issue where the farm_update module does not revert a view when the only thing that has changed is the order of the view's fields.
This is caused by the config_update.config_diff service which normalizes config and sorts by array keys alphabetically when comparing two config items. Because the views field order is determined by the order of the field keys (there is no weight), if the only thing that changes is the field order, then the view config is not considered updated, and farm_update does not revert the config.
Normalize source: https://git.drupalcode.org/project/config_update/-/blob/8.x-1.x/src/Conf...
This behavior can also be observed in the Config Update UI, for views at /admin/config/development/configuration/report/type/view
However, as noted in ConfigDiffer::same:
It is up to the particular implementing
* class to decide what normalizing means.
Steps to reproduce
- Enable
views_uiand modify the order of fields in thefarm_logview. - Confirm that the field order changed at /logs.
- Clear caches.
- Observe that the views field order remains the same and was not reverted.
Proposed resolution
Not sure if there is an easy solution to this. Maybe we could normalize view config in a different way ourselves? But are there other types of config that would common suffer from the same issue?
Remaining tasks
Identify solution and/or document this limitation
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #2
paul121 commentedComment #3
paul121 commentedComment #4
m.stentaHmm interesting. It does sound like this is ultimately a bug with the
config_updatemodule.It reminds me of this core issue that was resolved in Drupal 9.3.x: #2852557: Config export key order is not predictable, use config schema to order keys for maps
Relevant change record: https://www.drupal.org/node/3230199
Looking at the git blame for the lines in config_entity you referenced, it looks like most of that logic was added long before the core change: https://git.drupalcode.org/project/config_update/-/blame/8.x-1.x/src/Con...
So maybe config_update is due for some refactoring to take that into account? Maybe it doesn't need to do that re-sorting anymore, now that core does it based on the config schema definition?
Comment #5
m.stentaComment #6
m.stentaComment #7
m.stentaJust tested this again, and it's still an issue.
I created an upstream issue for it in Config Update: #3600959: Reverting the order of fields/filters/etc in Views does not work