Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.202
diff -u -p -r1.202 menu.inc
--- includes/menu.inc	29 Aug 2007 20:46:18 -0000	1.202
+++ includes/menu.inc	3 Sep 2007 21:59:26 -0000
@@ -462,6 +462,7 @@ function _menu_translate(&$router_item, 
     }
   }
   $router_item['href'] = implode('/', $link_map);
+  $router_item['options'] = array();
   _menu_check_access($router_item, $map);
 
   _menu_item_localize($router_item, $map);
@@ -1256,18 +1257,19 @@ function menu_set_active_trail($new_trai
     $trail = array();
     $trail[] = array('title' => t('Home'), 'href' => '<front>', 'options' => array(), 'type' => 0);
     $item = menu_get_item();
-    // We are on a tab.
+    // If we are on a tab, use the root item instead.
     if ($item['tab_parent']) {
-      $href = $item['tab_root'];
-    }
-    else {
-      $href = $item['href'];
+      $root_item = menu_get_item($item['tab_root']);
+      if ($root_item && $root_item['access']) {
+        $item = $root_item;
+      }
     }
+
     $tree = menu_tree_page_data(menu_get_active_menu_name());
     $curr = array_shift($tree);
 
     while ($curr) {
-      if ($curr['link']['href'] == $href) {
+      if ($curr['link']['href'] == $item['href']) {
         $trail[] = $curr['link'];
         $curr = FALSE;
       }
@@ -1279,6 +1281,12 @@ function menu_set_active_trail($new_trai
         $curr = array_shift($tree);
       }
     }
+    // Make sure the current page is in the trail (needed for the page title),
+    // but exclude tabs and the front page.
+    $last = count($trail) - 1;
+    if ($trail[$last]['href'] != $item['href'] && !(bool)($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) {
+      $trail[] = $item;
+    }
   }
   return $trail;
 }
