Index configurations are changing from export to export.

Created on 23 April 2019, over 5 years ago
Updated 15 April 2024, 7 months ago

Problem/Motivation

When an index gets exported it is including a set of dependencies to modules, as well as dependencies on other configurations.
So far so good - there are no surprises here, everything works.

My issue comes from the fact that when you edit the index setting and add a new dependency, instead of the GIT DIFF to show only one line added on the file, there is noise in the output due to the fact that some files are re-ordered. It requires too much mental effort to review such diffs.

Proposed resolution

Have some way to enforce ordering on the list of dependencies, so they are alphabetically ordered during serialization. Once that's done the output should be deterministic and the DIFFs will be as small as possible.

Remaining tasks

Discussion, patch etc.

User interface changes

None expected.

API changes

None expected.

Data model changes

None expected.

Release notes snippet

TBD.

Feature request
Status

Closed: duplicate

Version

1.0

Component

General code

Created by

🇧🇬Bulgaria ndobromirov

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.

  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    Nothing to do here, indeed but the issue is very annoying and 📌 Add orderby key to all sequences in core Active might take years until is fixed. Here's a workaround to whom it may concern:

    /**
     * Implements hook_ENTITY_TYPE_presave() for search_api_index entity type.
     *
     * On each config export, the Search API indexes dependencies are shuffled. This
     * is just a workaround until #2855675 is fixed.
     * @see https://www.drupal.org/i/2855675
     * @todo Remove this when https://www.drupal.org/i/2855675 lands.
     */
    function mymodule_search_api_index_presave(IndexInterface $index): void {
      $sorted = [];
      foreach ($index->getDependencies() as $type => $dependencies) {
        sort($dependencies);
        $sorted[$type] = $dependencies;
      }
      $index->set('dependencies', $sorted);
    }
    
Production build 0.71.5 2024