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().
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3442053-2.patch | 1.56 KB | casey |
Issue fork drupal-3442053
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
casey commentedComment #3
casey commentedComment #5
smustgrave commentedThank you for reporting.
As a next step will need a test case to show the issue.