diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 8688704..bf3c9f2 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1062,13 +1062,16 @@ function menu_tree($menu_name) { * - collapsed: The menu item has a submenu which is not shown. * - leaf: The menu item has no submenu. * - * @param $tree + * @param array $tree * A data structure representing the tree as returned from menu_tree_data. + * @param bool $add_active_classes + * (optional) Whether to mark items in the active trail with appriate CSS + * classes. If turned off, the data is useful for caching. * * @return * A structured array to be rendered by drupal_render(). */ -function menu_tree_output($tree, $add_active_classes = TRUE) { +function menu_tree_output(array $tree, $add_active_classes = TRUE) { $build = array(); $items = array(); @@ -1400,6 +1403,10 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = * - conditions: An associative array of custom database select query * condition key/value pairs; see _menu_build_tree() for the actual query. * + * If neither the 'active_trail', nor the 'only_active_trail' parameters are + * provided, the localized, access filtered menu tree is cached per user. If + * active trail items are marked, reusable caching is not possible. + * * @return * A fully built menu tree. */ @@ -1416,7 +1423,7 @@ function menu_build_tree($menu_name, array $parameters = array()) { // If there's no active trail tracking, then add per-user caching of the // localized, access-filtered menu subtrees. else { - global $user; + $user = \Drupal::request()->attributes->get('account'); $language_interface = language(Language::TYPE_INTERFACE); $trees = &drupal_static(__FUNCTION__, array());