Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.238
diff -u -r1.238 update.php
--- update.php	30 Nov 2007 12:19:10 -0000	1.238
+++ update.php	6 Dec 2007 12:04:44 -0000
@@ -334,19 +334,26 @@
   // Ensure system.module's updates appear first
   $form['start']['system'] = array();
 
-  foreach (module_list() as $module) {
+  $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
+  foreach ($modules as $module => $schema_version) {
     $updates = drupal_get_schema_versions($module);
-    if ($updates !== FALSE) {
+    if ($updates !== FALSE && $schema_version >= 0) {
+      // module_invoke returns NULL for nonexisting hooks, so if no updates
+      // are removed, it will == 0.
+      $last_removed = module_invoke($module, 'update_last_removed');
+      if ($schema_version < $last_removed) {
+        drupal_set_message(t("$module can not be updated. It's schema version is $schema_version and updates up to $last_removed have been removed. You need to install an older version of Drupal and update this module first if you want to use $module in the future."));
+        continue;
+      }
       $updates = drupal_map_assoc($updates);
       $updates[] = 'No updates available';
-      $default = drupal_get_installed_schema_version($module);
+      $default = $schema_version;
       foreach (array_keys($updates) as $update) {
-        if ($update > $default) {
+        if ($update > $schema_version) {
           $default = $update;
           break;
         }
       }
-
       $form['start'][$module] = array(
         '#type' => 'select',
         '#title' => $module .' module',
Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.50
diff -u -r1.50 install.inc
--- includes/install.inc	30 Nov 2007 12:19:10 -0000	1.50
+++ includes/install.inc	6 Dec 2007 12:37:10 -0000
@@ -22,8 +22,10 @@
  * Initialize the update system by loading all installed module's .install files.
  */
 function drupal_load_updates() {
-  foreach (module_list() as $module) {
-    module_load_install($module);
+  foreach (drupal_get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) {
+    if ($schema_version > -1) {
+      module_load_install($module);
+    }
   }
 }
 
@@ -58,10 +60,15 @@
  *
  * @param $module
  *   A module name.
+ * @param $reset
+ *   Set to TRUE after modifying the system table.
+ * @param $array
+ *   Set to TRUE if you want to get information about all modules in the 
+ *   system.
  * @return
  *   The currently installed schema version.
  */
-function drupal_get_installed_schema_version($module, $reset = FALSE) {
+function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
   static $versions = array();
 
   if ($reset) {
@@ -76,7 +83,7 @@
     }
   }
 
-  return $versions[$module];
+  return $array ? $versions : $versions[$module];
 }
 
 /**
Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.11
diff -u -r1.11 comment.install
--- modules/comment/comment.install	26 Nov 2007 19:55:15 -0000	1.11
+++ modules/comment/comment.install	6 Dec 2007 11:59:22 -0000
@@ -1,6 +1,8 @@
 <?php
 // $Id: comment.install,v 1.11 2007/11/26 19:55:15 goba Exp $
 
+require_once drupal_get_path('module', 'comment') .'/comment.module';
+
 /**
  * Implementation of hook_enable().
  */
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.202
diff -u -r1.202 system.install
--- modules/system/system.install	4 Dec 2007 16:39:22 -0000	1.202
+++ modules/system/system.install	6 Dec 2007 12:00:41 -0000
@@ -1039,6 +1039,10 @@
  * @defgroup updates-4.7.x-extra Extra system updates for 4.7.x
  * @{
  */
+ 
+function system_update_last_removed() {
+  return 179;
+}
 
 function system_update_180() {
   $ret = array();
