diff -ur d258/includes/menu.inc d263/includes/menu.inc --- d258/includes/menu.inc 2010-09-04 07:39:09.000000000 +0200 +++ d263/includes/menu.inc 2010-09-04 07:39:52.000000000 +0200 @@ -170,7 +170,7 @@ * Every set of local tasks should provide one "default" task, that links to the * same path as its parent when clicked. */ -define('MENU_DEFAULT_LOCAL_TASK', MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT); +define('MENU_DEFAULT_LOCAL_TASK', MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT | MENU_VISIBLE_IN_BREADCRUMB); /** * Menu type -- An action specific to the parent, usually rendered as a link. @@ -1123,7 +1123,6 @@ $tree_parameters = array( 'min_depth' => 1, 'max_depth' => $max_depth, - 'only_active_trail' => $only_active_trail, ); // Parent mlids; used both as key and value to ensure uniqueness. // We always want all the top-level links with plid == 0. @@ -1145,8 +1144,14 @@ $parents = $active_trail; $expanded = variable_get('menu_expanded', array()); + // If we are asked to build links for the active trail only, then skip + // the entire 'expanded' handling. Since there is no breadcrumb on + // access denied pages, it is safe to set this only here. + if ($only_active_trail) { + $tree_parameters['only_active_trail'] = TRUE; + } // Check whether the current menu has any links set to be expanded. - if (!$only_active_trail && in_array($menu_name, $expanded)) { + elseif (in_array($menu_name, $expanded)) { // Collect all the links set to be expanded, and then add all of // their children to the list as well. do { @@ -1160,15 +1165,16 @@ ->execute(); $num_rows = FALSE; foreach ($result as $item) { - $parents[] = $item['mlid']; + $parents[$item['mlid']] = $item['mlid']; $num_rows = TRUE; } } while ($num_rows); + + $tree_parameters['expanded'] = $parents; } - $tree_parameters['expanded'] = $parents; $tree_parameters['active_trail'] = $active_trail; } - // If access is denied, only show top-level links in the menu. + // If access is denied, we only show top-level links in menus. else { $tree_parameters['expanded'] = $active_trail; $tree_parameters['active_trail'] = $active_trail; @@ -2315,14 +2321,14 @@ if (!empty($item['access'])) { $active_trail = menu_get_active_trail(); - foreach ($active_trail as $parent) { - $breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']); - } + // Don't show a link to the current page in the breadcrumb trail. $end = end($active_trail); + if ($item['href'] == $end['href'] || ($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) { + array_pop($active_trail); + } - // Don't show a link to the current page in the breadcrumb trail. - if ($item['href'] == $end['href'] || (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT && $end['href'] != '')) { - array_pop($breadcrumb); + foreach ($active_trail as $parent) { + $breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']); } } return $breadcrumb; diff -ur d258/modules/menu/menu.test d263/modules/menu/menu.test --- d258/modules/menu/menu.test 2010-09-04 07:39:09.000000000 +0200 +++ d263/modules/menu/menu.test 2010-09-04 07:39:52.000000000 +0200 @@ -774,12 +774,15 @@ $nid1 = $node1->nid; $expected = $home; $this->assertBreadcrumb("node/$nid1", $expected); + // The node itself should not be contained in the breadcrumb on the default + // local task, since there is no difference between both pages. + $this->assertBreadcrumb("node/$nid1/view", $expected); $expected += array( "node/$nid1" => $node1->title, ); $this->assertBreadcrumb("node/$nid1/edit", $expected); - // Verify that node listing page still contains "Home" only. + // Verify that breadcrumb on node listing page contains "Home" only. $expected = array(); $this->assertBreadcrumb('node', $expected); @@ -811,6 +814,9 @@ $expected = $home; $this->assertBreadcrumb("node/$nid2", $expected); + // The node itself should not be contained in the breadcrumb on the + // default local task, since there is no difference between both pages. + $this->assertBreadcrumb("node/$nid2/view", $expected); $expected += array( "node/$nid2" => $node2->menu['link_title'], );