Parameter $max_relative_depth in method loadSubtreeData from MenuTreeStorage has no effect

Created on 16 June 2025, 21 days ago

Problem/Motivation

I am building a block that loads a huge menu, the core block tries to load many items at once causing performance issues so I'm trying to load the tree more progressively. I noticed the function loadSubtreeData from the storage
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Menu%21Me...
but reading the implementation it doesn't use the $max_relative_depth parameter

Steps to reproduce

Call the function programmatically with a value for $max_relative_depth = 1 and notice it loads the whole subtree instead of just one level.
As far as I searched this method is not used in Drupal core.

Proposed resolution

Configure parameters like this
$parameters->setRoot($id)->onlyEnabledLinks()->setMaxDepth($max_relative_depth);

Remaining tasks

Code

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

Calling loadSubtreeData with $max_relative_depth from MenuTreeStorage correctly limits the subtree

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

menu system

Created by

🇪🇸Spain rodrigoaguilera Barcelona

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024