summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--content.install14
-rw-r--r--content.module35
3 files changed, 45 insertions, 5 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 420f898..7b2f50a 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -3,6 +3,7 @@
CCK 6.2-dev
===========
+- #318227 Clean up update abort logic to more clearly explain what still needs to be done, add a helper function to prevent dangerous database operations until database is updated.
- #317232 Change css file name from content.css to content-module.css to avoid namespace collisions.
- #316656 Default weight must be zero, not NULL, or form ordering will be incorrect.
- #107407 by dopry, optimization patch, do nothing in hook_form_alter() and hook_nodeapi() if there are no fields.
diff --git a/content.install b/content.install
index fcf2131..533b838 100644
--- a/content.install
+++ b/content.install
@@ -229,15 +229,23 @@ 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.');
+ drupal_set_message(t("Updates for CCK-related modules are not run until the modules are enabled on the <a href=\"@admin-modules-path\">administer modules page</a>. When you enable them, 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);
+ // The content module is not enabled, nothing else can happen.
+ if ($module && !module_exists('content') && module_exists($module)) {
+ $query_message = t('!module.module has updates but cannot be updated because content.module is not enabled.<br />If and when content.module is enabled, you will need to re-run the update script.', array('!module' => $module));
+ }
+ // The requested module is not enabled, which may be intentional.
+ // Just let the user know there are updates to be processed if updated later.
+ elseif ($module) {
+ $query_message = t('!module.module has updates and is available in the modules folder but is not enabled.<br />If and when it is enabled, you will need to re-run the update script.', array('!module' => $module));
+ }
$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.'));
+ $ret['#abort'] = array('success' => FALSE, 'query' => t('Some updates are still pending.<br/>Please re-run the update script.'));
return $ret;
}
}
diff --git a/content.module b/content.module
index bf95c68..918a306 100644
--- a/content.module
+++ b/content.module
@@ -95,7 +95,7 @@ function content_menu() {
// Make sure this doesn't fire until content_types is working,
// needed to avoid errors on initial installation.
- if (!defined('MAINTENANCE_MODE')) {
+ if (!defined('MAINTENANCE_MODE') && content_is_updated()) {
foreach (node_get_types() as $type) {
$type_name = $type->type;
$content_type = content_types($type_name);
@@ -500,6 +500,11 @@ function content_notify($op, $module) {
content_clear_type_cache();
break;
case 'disable':
+ // When CCK modules are disabled before content module's update is run,
+ // we can't do this.
+ if (!content_is_updated()) {
+ return FALSE;
+ }
db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
content_clear_type_cache(TRUE);
@@ -514,6 +519,11 @@ function content_notify($op, $module) {
* The name of the module to update on.
*/
function content_associate_fields($module) {
+ // When CCK modules are enabled before content module's update is run,
+ // we can't do this.
+ if (!content_is_updated()) {
+ return FALSE;
+ }
$module_fields = module_invoke($module, 'field_info');
if ($module_fields) {
foreach ($module_fields as $name => $field_info) {
@@ -883,6 +893,11 @@ function _content_sort_items_value_helper($a, $b) {
* Handle storage ops for _content_field_invoke_default().
*/
function content_storage($op, $node) {
+ // Don't try this before content module's update is run.
+ if (!content_is_updated()) {
+ return FALSE;
+ }
+
$type_name = $node->type;
$type = content_types($type_name);
@@ -1296,7 +1311,9 @@ function _content_type_info($reset = FALSE) {
// For instance: when first enabled and called from content_menu(),
// or when uninstalled and some subsequent field module uninstall
// attempts to refresh the data.
- if (!db_table_exists(content_field_tablename())) {
+
+ // Don't try this before content module's update is run.
+ if (!content_is_updated()) {
return array();
}
@@ -1866,6 +1883,20 @@ function content_cache_tablename() {
}
/**
+ * Test before trying database operations.
+ */
+function content_is_updated() {
+ if (!db_table_exists(content_field_tablename())) {
+ return FALSE;
+ }
+ if (!db_column_exists(content_field_tablename(), 'active')
+ || !db_column_exists(content_field_tablename(), 'module')) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
* A basic schema used by all field and type tables.
*
* This will only add the columns relevant for the specified field.