Relative links in a menu block are from another request

Created on 15 September 2020, over 4 years ago
Updated 4 April 2024, 10 months ago

Problem/Motivation

We have used the menu token module together with the menu block module to create a menu which uses the current node.
This menu block is not cached so the links are generated on the active request.
The menu token module rewrites the links in the menu_tree database table.
The problem lies in the MenuLinkTreeMenuToken class.
It is using the parent class to load the menu tree, but that tree is loaded from the database.
If you spam requests on multiple urls those urls each rewrite the url in the menu_tree table.
It is possible to influence the menu for other requests.

Steps to reproduce

Add a menu with relative links based on for example the current node.
Add the menu block.
Start actively requesting another node which has the same menu.
Notice that at random if you time it just right you receive the menu from another request.

Proposed resolution

Never write temporary data to a table row which can be used for other requests.
I have a quick bypass for users who suffer from this issue I will add the patch as an attachment.
(This is probably not the best solution.)

Remaining tasks

Figure out what the correct way is to correct this behavior.

🐛 Bug report
Status

Needs review

Version

9.1

Component

Code

Created by

🇳🇱Netherlands thomasdik

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.

  • 🇦🇹Austria jordik

    I have the same problem as in #12. Using D10 and 9.1.x-dev.
    If there are menu links with children, the urls are not replaced.
    The patch in #12 solves this issue perfectly.

Production build 0.71.5 2024