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?

Comments

andrewsuth created an issue. See original summary.

Version: 9.1.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bbu23’s picture

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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.