diff --git includes/menu.inc includes/menu.inc index 83480eb..d038f50 100644 --- includes/menu.inc +++ includes/menu.inc @@ -1133,12 +1133,18 @@ function menu_tree_page_data($menu_name, $max_depth = NULL) { // parameters accordingly. if ($item['access']) { // Find a menu link corresponding to the current path. - if ($top_link = menu_link_get_preferred()) { - // Use all the coordinates, except the last one because there - // can be no child beyond the last column. - for ($i = 1; $i < MENU_MAX_DEPTH; $i++) { - if ($top_link['p' . $i]) { - $active_trail[$top_link['p' . $i]] = $top_link['p' . $i]; + if ($active_link = menu_link_get_preferred()) { + // The active link may only be taken into account to build the + // active trail, if it resides in the requested menu. Otherwise, + // we'd needlessly re-run _menu_build_tree() queries for every menu + // on every page. + if ($active_link['menu_name'] == $menu_name) { + // Use all the coordinates, except the last one because there + // can be no child beyond the last column. + for ($i = 1; $i < MENU_MAX_DEPTH; $i++) { + if ($active_link['p' . $i]) { + $active_trail[$active_link['p' . $i]] = $active_link['p' . $i]; + } } } }