Recipes are sorted randomly on Recipes tab

Created on 13 December 2024, 8 days ago

Problem/Motivation

Symfony finder is used to find all recipes in the filesystem, see Recipes::getFinder():

    $finder = Finder::create()
      ->files()
      ->in($search_in)
      ->depth(1)
      // Without this, recipes that are symlinked into the project (e.g.,
      // path repositories) will be missed.
      ->followLinks()
      // The example recipe exists for documentation purposes only.
      ->notPath('example/')
      ->name('recipe.yml');

    $allowed = $this->configFactory->get('project_browser.admin_settings')
      ->get('allowed_projects.' . $this->getPluginId());
    if ($allowed) {
      $finder->path(
        array_map(fn (string $name) => $name . '/', $allowed),
      );
    }
    return $finder;

We are not adding a sort to this finder, nor sorting it afterwards (because the Recipes tab does not have the sort element). This means that the order in which the recipes are returned by the Symfony finder is random and can change in different enviroments. I experienced two different sorts on two installations recently:

First site: https://www.drupal.org/files/issues/2024-12-13/recipes1.png β†’
Second site: https://www.drupal.org/files/issues/2024-12-13/recipes2.png β†’

I think we should add a default sort by the recipe name/filename, to have it consistent.

Steps to reproduce

Install Drupal CMS
Go to /admin/modules/browse and open Recipes tab
Examine the order of the recipes (they are not sorted)
Try installing Drupal CMS on diffent system and repeat the steps (the order will probably be different)

Proposed resolution

Add order by recipe name/filename.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia poker10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024