Index: content.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.install,v
retrieving revision 1.85.2.16
diff -u -r1.85.2.16 content.install
--- content.install	16 Sep 2008 15:33:41 -0000	1.85.2.16
+++ content.install	22 Sep 2008 14:04:46 -0000
@@ -218,6 +218,32 @@
 }
 
 /**
+ * Helper function for module updates :
+ *
+ *
+ * @param $module
+ *   The name of the module being updated.
+ *   The function will chack that this module is actually enabled
+ *   before running the updates.
+ */
+function content_check_update($module = NULL) {
+  $ret = array();
+  // Check that modules are enabled before running their updates.
+  if (!module_exists('content') || ($module && !module_exists($module))) {
+    drupal_set_message(t("Updates for CCK-related modules require the modules to be enabled on the <a href=\"@admin-modules-path\">administer modules page</a>. After doing so, you'll need to return to <a href=\"@update-php\">update.php</a> and run the remaining updates.", array('@admin-modules-path' => url('admin/build/modules'), '@update-php' => base_path() .'update.php?op=selection')), 'warning', FALSE);
+    $query_message = $module ? t('content.module and !module.module need to be enabled.<br/>Please enable them and re-run the update script.', array('!module' => $module)) : t('content.module needs to be enabled.<br/>Please enable it and re-run the update script.');
+    $ret['#abort'] = array('success' => FALSE, 'query' => $query_message);
+    return $ret;
+  }
+  // Check that content.module is up-to-date before running field module updates.
+  if ($module && (drupal_get_installed_schema_version('content', TRUE) < max(drupal_get_schema_versions('content')))) {
+    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning', FALSE);
+    $ret['#abort'] = array('success' => FALSE, 'query' => t('Updates for content.module need to be run first.<br/>Please re-run the update script.'));
+    return $ret;
+  }
+}
+
+/**
  * Add module name to fields table to make it easier to identify the fields to delete when a module
  * is uninstalled.
  *
@@ -225,6 +251,10 @@
  * is no other way to find the associated fields.
  */
 function content_update_6000() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   $ret = array();
 
   drupal_load('module', 'content');
@@ -268,6 +298,10 @@
  * with 'content_field'.
  */
 function content_update_6001() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   $ret = array();
   drupal_load('module', 'content');
   if (db_table_exists('content_node_field')) {
@@ -285,6 +319,10 @@
  * Switching to adding those tables only when needed.
  */
 function content_update_6002() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   $ret = array();
 
   drupal_load('module', 'content');
@@ -314,6 +352,10 @@
  * This update function will only be useful for early D6 testers...
  */
 function content_update_6003() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   $ret = array();
   if (db_column_exists('content_node_field', 'columns')) {
     db_change_field($ret, 'content_node_field', 'columns', 'db_columns', array('type' => 'text', 'size' => 'medium', 'not null' => TRUE));
@@ -326,6 +368,10 @@
  * Large tables might deserve a multipass update.
  */
 function content_update_6004(&$sandbox) {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   $ret = array();
 
   // Do nothing if the indexes were already created by D5's content_update_1009.
@@ -367,6 +413,10 @@
  * Add 'locked' property for fields.
  */
 function content_update_6005() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   $ret = array();
   drupal_load('module', 'content');
   db_add_field($ret, content_field_tablename(), 'locked', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0));
@@ -377,6 +427,10 @@
  * Make sure the 'locked' column is NOT NULL (error in previous content_update_6005().
  */
 function content_update_6006() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   $ret = array();
   drupal_load('module', 'content');
   db_change_field($ret, content_field_tablename(), 'locked', 'locked', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0));
@@ -388,5 +442,9 @@
  * are updated.
  */
 function content_update_6007() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
   return array();
 }
Index: modules/userreference/userreference.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/userreference/userreference.install,v
retrieving revision 1.23.2.4
diff -u -r1.23.2.4 userreference.install
--- modules/userreference/userreference.install	7 Sep 2008 14:52:32 -0000	1.23.2.4
+++ modules/userreference/userreference.install	22 Sep 2008 14:04:47 -0000
@@ -45,14 +45,10 @@
  * Placeholder update to set newly installed versions to the latest update number.
  */
 function userreference_update_6000() {
-  $ret = array();
-
-  // OK, stupid, but this is just for consistency...
-  if (drupal_get_installed_schema_version('content') < 6000) {
-    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning');
-    $ret['#abort'] = array('success' => FALSE, 'query' => t('Updates for content.module need to be run first.<br/>Please re-run the update script.'));
-    return $ret;
+  if ($abort = content_check_update('userreference')) {
+    return $abort;
   }
 
+  $ret = array();
   return $ret;
 }
\ No newline at end of file
Index: modules/optionwidgets/optionwidgets.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/optionwidgets/optionwidgets.install,v
retrieving revision 1.23.2.4
diff -u -r1.23.2.4 optionwidgets.install
--- modules/optionwidgets/optionwidgets.install	7 Sep 2008 14:52:32 -0000	1.23.2.4
+++ modules/optionwidgets/optionwidgets.install	22 Sep 2008 14:04:46 -0000
@@ -49,14 +49,12 @@
  * the module names in the field and instance tables, so do it here.
  */
 function optionwidgets_update_6000() {
-  $ret = array();
-
-  if (drupal_get_installed_schema_version('content') < 6000) {
-    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning');
-    $ret['#abort'] = array('success' => FALSE, 'query' => t('Updates for content.module need to be run first.<br/>Please re-run the update script.'));
-    return $ret;
+  if ($abort = content_check_update('optionwidgets')) {
+    return $abort;
   }
 
+  $ret = array();
+
   drupal_load('module', 'content');
   $ret[] = update_sql("UPDATE {". content_instance_tablename() ."} SET widget_type = 'optionwidgets_select' WHERE widget_type = 'options_select'");
   $ret[] = update_sql("UPDATE {". content_instance_tablename() ."} SET widget_type = 'optionwidgets_onoff' WHERE widget_type = 'options_onoff'");
Index: modules/fieldgroup/fieldgroup.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/fieldgroup/fieldgroup.install,v
retrieving revision 1.34.2.10
diff -u -r1.34.2.10 fieldgroup.install
--- modules/fieldgroup/fieldgroup.install	20 Sep 2008 14:00:37 -0000	1.34.2.10
+++ modules/fieldgroup/fieldgroup.install	22 Sep 2008 14:04:46 -0000
@@ -184,14 +184,12 @@
  * Move fieldgroup tables to the content_* namespace.
  */
 function fieldgroup_update_6000() {
-  $ret = array();
-
-  if (drupal_get_installed_schema_version('content') < 6000) {
-    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning');
-    $ret['#abort'] = array('success' => FALSE, 'query' => t('Updates for content.module need to be run first.<br/>Please re-run the update script.'));
-    return $ret;
+  if ($abort = content_check_update('fieldgroup')) {
+    return $abort;
   }
 
+  $ret = array();
+
   db_rename_table($ret, 'node_group', 'content_group');
   db_rename_table($ret, 'node_group_fields', 'content_group_fields');
   variable_set('fieldgroup_schema_version', 6000);
@@ -206,6 +204,10 @@
  * New D6 installs earlier than RC5 need this, as it was missing in fieldgroup_install.
  */
 function fieldgroup_update_6001() {
+  if ($abort = content_check_update('fieldgroup')) {
+    return $abort;
+  }
+
   $ret = array();
   $ret[] = update_sql("UPDATE {system} SET weight = 9 WHERE name = 'fieldgroup'");
   return $ret;
@@ -216,6 +218,10 @@
  * This was missing in D6 releases earlier than RC5. Ensure we don't run this twice.
  */
 function fieldgroup_update_6002() {
+  if ($abort = content_check_update('fieldgroup')) {
+    return $abort;
+  }
+
   $ret = array();
   if (db_table_exists('node_group')) {
     db_rename_table($ret, 'node_group', 'content_group');
@@ -229,6 +235,10 @@
  * Remove tinyint (127) limitation on group weights.
  */
 function fieldgroup_update_6003() {
+  if ($abort = content_check_update('fieldgroup')) {
+    return $abort;
+  }
+
   $ret = array();
   db_change_field($ret, 'content_group', 'weight', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
   return $ret;
@@ -238,6 +248,10 @@
  * Add 'type' property for fieldgroups.
  */
 function fieldgroup_update_6004() {
+  if ($abort = content_check_update('fieldgroup')) {
+    return $abort;
+  }
+
   $ret = array();
   db_add_field($ret, 'content_group', 'group_type', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => 'standard'));
   $ret[] = update_sql("DELETE FROM {cache_content} WHERE cid='fieldgroup_data'");
Index: modules/number/number.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/number/number.install,v
retrieving revision 1.28.2.4
diff -u -r1.28.2.4 number.install
--- modules/number/number.install	7 Sep 2008 14:52:32 -0000	1.28.2.4
+++ modules/number/number.install	22 Sep 2008 14:04:46 -0000
@@ -45,14 +45,12 @@
  * Rename old decimal fields, which were really floats, to float
  */
 function number_update_6000() {
-  $ret = array();
-
-  if (drupal_get_installed_schema_version('content') < 6000) {
-    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning');
-    $ret['#abort'] = array('success' => FALSE, 'query' => t('Updates for content.module need to be run first.<br/>Please re-run the update script.'));
-    return $ret;
+  if ($abort = content_check_update('number')) {
+    return $abort;
   }
 
+  $ret = array();
+
   drupal_load('module', 'content');
   $ret[] = update_sql("UPDATE {". content_field_tablename() ."} SET type='number_float' WHERE type = 'number_decimal'");
 
Index: modules/nodereference/nodereference.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/nodereference/nodereference.install,v
retrieving revision 1.25.2.4
diff -u -r1.25.2.4 nodereference.install
--- modules/nodereference/nodereference.install	7 Sep 2008 14:52:32 -0000	1.25.2.4
+++ modules/nodereference/nodereference.install	22 Sep 2008 14:04:46 -0000
@@ -45,14 +45,12 @@
  * All fields must allow NULL values to indicate empty fields.
  */
 function nodereference_update_6000() {
-  $ret = array();
-
-  if (drupal_get_installed_schema_version('content') < 6000) {
-    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning');
-    $ret['#abort'] = array('success' => FALSE, 'query' => t('Updates for content.module need to be run first.<br/>Please re-run the update script.'));
-    return $ret;
+  if ($abort = content_check_update('nodereference')) {
+    return $abort;
   }
 
+  $ret = array();
+
   drupal_load('module', 'content');
   content_clear_type_cache();
   include_once('./'. drupal_get_path('module', 'content') .'/content.install');
Index: modules/text/text.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/text/text.install,v
retrieving revision 1.37.2.5
diff -u -r1.37.2.5 text.install
--- modules/text/text.install	7 Sep 2008 14:52:32 -0000	1.37.2.5
+++ modules/text/text.install	22 Sep 2008 14:04:47 -0000
@@ -49,14 +49,12 @@
  *
  */
 function text_update_6000() {
-  $ret = array();
-
-  if (drupal_get_installed_schema_version('content') < 6000) {
-    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning');
-    $ret['#abort'] = array('success' => FALSE, 'query' => t('Updates for content.module need to be run first.<br/>Please re-run the update script.'));
-    return $ret;
+  if ($abort = content_check_update('text')) {
+    return $abort;
   }
 
+  $ret = array();
+
   drupal_load('module', 'content');
   $result = db_query("SELECT * FROM {". content_instance_tablename() ."} WHERE widget_type = 'text'");
   while ($field_instance = db_fetch_array($result)) {
@@ -78,6 +76,10 @@
  *
  */
 function text_update_6001() {
+  if ($abort = content_check_update('text')) {
+    return $abort;
+  }
+
   $ret = array();
 
   drupal_load('module', 'content');
