menu.default_tree_manipulators:generateIndexAndSort sorting is not always alphabetical

Created on 19 April 2024, 8 months ago

Problem/Motivation

The default menu tree manipulator generateIndexAndSort should sort menu items by weight and then by title (alphabetically). However if two menu items have the same weight and a title starting with the same text, the item with the longer title typically is (incorrectly) sorted before the item with the shorter title.

The manipulator uses ksort to sort the menu items. The keys consist of a fixed prefix, the weight, name and plugin id of the menu item. The addition of the plugin id is required to ensure the keys are unique, however results in this incorrect sorting.

Steps to reproduce

Add two or more menu links to a menu with the same weight:

  • Menu link A
  • Menu link A (extra text)

Verify that the menu links are incorrectly sorted:

  • Menu link A (extra text)
  • Menu link A

Proposed resolution

Instead of using ksort() on a generated/composed key, simply use uasort().

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Menu systemΒ  β†’

Last updated about 19 hours ago

Created by

πŸ‡³πŸ‡±Netherlands casey

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024