MenuActiveTrail inconsistent since #3025394 introduced

Created on 26 April 2021, over 3 years ago
Updated 19 February 2024, 10 months ago

Since the fix #3025394: MenuActiveTrail should keep its cid (cache id) to avoid wrong cache sets for 403 was introduced in 9.1.x, I have noticed inconsistencies in the active menu trail. Since the patch, all of the active menu items are incorrect and instead have the active route as another route in the menu.

Before patch (active trails are correct)

/about -> /about is active (node 70)
/map -> /map is active (node 4)
/guide -> /guide is active (a Views page)
/privacy-policy -> /privacy-policy is active (node 1)

After patch (active trails are incorrect)

/about -> /privacy-policy is active (node 1)
/map -> /privacy-policy is active (node 1)
/guide -> /privacy-policy is active (node 1)
/privacy-policy -> /privacy-policy is active (node 1)

Interestingly, the incorrect route being points to is also node 1 on the project. Might be a niche case I have stumbled upon?

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Menu system 

Last updated about 15 hours ago

Created by

🇮🇹Italy andrewsuth

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 bbu23

    Hi. I also have issues with the active trail in menus.
    I was looking at the web/core/lib/Drupal/Core/Cache/Context/MenuActiveTrailsCacheContext.php file, which calls web/core/lib/Drupal/Core/Menu/MenuActiveTrail.php, where in my case two different paths are getting the default $active_trail = ['' => '']; instead of the actual trail. So, a page like home can == to a page like search because of that. This means that whichever page gets accessed first, that one will be the active trail and gets cached like that.

Production build 0.71.5 2024