=== modified file 'includes/menu.inc'
--- includes/menu.inc	2007-09-26 18:14:05 +0000
+++ includes/menu.inc	2007-09-29 18:04:38 +0000
@@ -1122,8 +1122,8 @@ function menu_local_tasks($level = 0, $r
         }
       }
       $path = $next_path;
-      $tabs[$item['number_parts']]['count'] = $count;
-      $tabs[$item['number_parts']]['output'] = $tabs_current;
+      $tabs[$item['depth']]['count'] = $count;
+      $tabs[$item['depth']]['output'] = $tabs_current;
     }
 
     // Find all tabs at the same level or above the current one.
@@ -1164,8 +1164,8 @@ function menu_local_tasks($level = 0, $r
       }
       $path = $next_path;
       $parent = $next_parent;
-      $tabs[$item['number_parts']]['count'] = $count;
-      $tabs[$item['number_parts']]['output'] = $tabs_current;
+      $tabs[$item['depth']]['count'] = $count;
+      $tabs[$item['depth']]['output'] = $tabs_current;
     }
     // Sort by depth.
     ksort($tabs);
@@ -1925,6 +1925,7 @@ function _menu_router_build($callbacks) 
       // Non-tab items.
       $item['tab_parent'] = '';
       $item['tab_root'] = $path;
+      $item['depth'] = 0;
     }
     for ($i = $item['_number_parts'] - 1; $i; $i--) {
       $parent_path = implode('/', array_slice($item['_parts'], 0, $i));
@@ -1935,6 +1936,7 @@ function _menu_router_build($callbacks) 
         if (!isset($item['tab_parent'])) {
           // Parent stores the parent of the path.
           $item['tab_parent'] = $parent_path;
+          $item['depth'] = $parent['depth'] + 1;
         }
         if (!isset($item['tab_root']) && !$parent['_tab']) {
           $item['tab_root'] = $parent_path;
@@ -1996,17 +1998,17 @@ function _menu_router_build($callbacks) 
     db_query("INSERT INTO {menu_router}
       (path, load_functions, to_arg_functions, access_callback,
       access_arguments, page_callback, page_arguments, fit,
-      number_parts, tab_parent, tab_root,
+      number_parts, depth, tab_parent, tab_root,
       title, title_callback, title_arguments,
       type, block_callback, description, position, weight, file)
       VALUES ('%s', '%s', '%s', '%s',
       '%s', '%s', '%s', %d,
-      %d, '%s', '%s',
+      %d, %d, '%s', '%s',
       '%s', '%s', '%s',
       %d, '%s', '%s', '%s', %d, '%s')",
       $path, $item['load_functions'], $item['to_arg_functions'], $item['access callback'],
       serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['_fit'],
-      $item['_number_parts'], $item['tab_parent'], $item['tab_root'],
+      $item['_number_parts'], $item['depth'], $item['tab_parent'], $item['tab_root'],
       $item['title'], $item['title callback'], serialize($item['title arguments']),
       $item['type'], $item['block callback'], $item['description'], $item['position'], $item['weight'], $item['include file']);
   }

=== modified file 'modules/system/system.schema'
--- modules/system/system.schema	2007-09-11 19:14:34 +0000
+++ modules/system/system.schema	2007-09-29 18:07:12 +0000
@@ -107,6 +107,7 @@ function system_schema() {
       'page_arguments'   => array('type' => 'text', 'not null' => FALSE),
       'fit'              => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
       'number_parts'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
+      'depth'            => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
       'tab_parent'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
       'tab_root'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
       'title'            => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),

