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

  1. Enable views_ui and modify the order of fields in the farm_log view.
  2. Confirm that the field order changed at /logs.
  3. Clear caches.
  4. 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

paul121 created an issue. See original summary.

paul121’s picture

Title: farm_update does revert views with reordered fields » farm_update does not revert views with reordered fields
paul121’s picture

Issue summary: View changes
m.stenta’s picture

Hmm interesting. It does sound like this is ultimately a bug with the config_update module.

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?

m.stenta’s picture

Version: 2.x-dev » 3.x-dev
m.stenta’s picture

Version: 3.x-dev » 4.x-dev
m.stenta’s picture

Just 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