Consistently sort filter formats to simplify config exports

Created on 29 November 2018, almost 6 years ago
Updated 11 November 2023, about 1 year ago

Problem/Motivation

As mentioned at πŸ“Œ Config export key order is not predictable, use config schema to order keys for maps Fixed , config export ordering isn't predictable. \Drupal\filter\Entity\FilterFormat orders filters at \Drupal\filter\Entity\FilterFormat::filters() and \Drupal\filter\Entity\FilterFormat::preSave(), but those methods only update the order of filters inside of the FilterPluginCollection, and not the $filters property on FilterFormat. This happens because \Drupal\Core\Plugin\DefaultLazyPluginCollection::getConfiguration() preserves the original order so the sort in FilterFormat::preSave() does not work as expected.

This can lead to config that is not imported cleanly, and it's especially noticeable when moving config across sites or with config_split.

Steps to reproduce

Proposed resolution

Add an orderby to the filter format schema so that the sort in the configuration file is consistent.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

Filter format filter configuration will be sorted by key. Note this does not affect the filter format filter plugin collection sorting at all.

When updating Drupal to a version with this change, the filter formats may be re-ordered in exported configuration YAML files but afterwards they will remain sorted consistently. (See commit cf2fd86fc for an example of such sort-order changes that may occur after a config export.)

Module and distribution maintainers should make sure their default configuration is sorted in order to minimize diffs when updating.

Release notes snippet

Filter formats are now consistently sorted. Exported filter format configuration may need re-exporting after updating, but afterwards they will remain consistent.

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
FilterΒ  β†’

Last updated about 5 hours ago

No maintainer
Created by

πŸ‡¨πŸ‡¦Canada deviantintegral

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.

Production build 0.71.5 2024