Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There's a $max_depth parameter of both menu_tree_all_data() and menu_tree_page_data() that we could use to limit the size of the returned menu tree to just those that we need for the configured block. We should use that parameter.
Comments
Comment #1
JohnAlbinComment #3
coredumperror CreditAttribution: coredumperror commentedOne of my sites' menu blocks broke because of this change. Since the "Maximum depth" value from the configure block page had not been in use, we had left it at 1 (might have been the default value? Not sure). This meant that our menu block which used the "Children of active menu item" option started printing a blank menu, since the relevant items were beyond the "Maximum depth" value. Setting "Maximum depth" to 2 fixed it.
This may be mostly our fault for setting the Maximum Depth to 1, but since it worked in the previous version, and broke with 1.4, that's still bad. Maybe add a warning message if any menu blocks are detected with both the "Children of active menu item" and "Maximum depth = 1" options set, since that's guaranteed to be broken?
Comment #4
stefan.r CreditAttribution: stefan.r commentedJust a heads up, a patch has been posted in #2283897: "starting level follow active menu item" broken by max_depth variable for the bug this commit has introduced.