=== modified file 'modules/system/system.install'
--- modules/system/system.install	2007-11-26 19:55:15 +0000
+++ modules/system/system.install	2007-11-30 15:03:04 +0000
@@ -2347,7 +2347,7 @@ function system_update_6021() {
     $_SESSION['system_update_6021']++;
   }
 
-  if ($_SESSION['system_update_6021'] >= $_SESSION['system_update_6021_max']) {
+  if (!db_result(db_query('SELECT * FROM {menu} WHERE updated = 0'))) {
     $result = db_query('SELECT * FROM {menu_links} WHERE updated = 1 AND has_children = 0 AND customized = 0 ORDER BY depth DESC');
     // Remove all items that are not customized.
     while ($item = db_fetch_array($result)) {

