summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-12-17 12:23:01 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-12-17 12:23:01 +0000
commitdfe1225147f48fa36db8507020795278c9270bda (patch)
tree3559e3230651a51ac50fc992c1ae0dd5800ca901
parenta0bea004022d38c9b145a3652f44820b18727456 (diff)
downloadbrdo-dfe1225147f48fa36db8507020795278c9270bda.tar.gz
brdo-dfe1225147f48fa36db8507020795278c9270bda.tar.bz2
#194310 by chx, catch, KarenS: run updates for disabled but previously installed modules, if they are compatible with the current system
-rw-r--r--includes/install.inc15
-rw-r--r--modules/comment/comment.install2
-rw-r--r--modules/system/system.install4
-rw-r--r--update.php65
4 files changed, 63 insertions, 23 deletions
diff --git a/includes/install.inc b/includes/install.inc
index 2ce311ee5..87ae7ff7b 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -22,8 +22,10 @@ define('FILE_NOT_EXECUTABLE', 128);
* 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 @@ function drupal_get_schema_versions($module) {
*
* @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 @@ function drupal_get_installed_schema_version($module, $reset = FALSE) {
}
}
- return $versions[$module];
+ return $array ? $versions : $versions[$module];
}
/**
diff --git a/modules/comment/comment.install b/modules/comment/comment.install
index 5f919bcc5..35a1e56a6 100644
--- a/modules/comment/comment.install
+++ b/modules/comment/comment.install
@@ -1,6 +1,8 @@
<?php
// $Id$
+drupal_load('module', 'comment');
+
/**
* Implementation of hook_enable().
*/
diff --git a/modules/system/system.install b/modules/system/system.install
index 510283dfc..e133b0ecd 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1043,6 +1043,10 @@ function system_schema() {
* @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();
diff --git a/update.php b/update.php
index ddf8bfd01..f56aebe40 100644
--- a/update.php
+++ b/update.php
@@ -187,19 +187,32 @@ function update_script_selection_form() {
// 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) {
+ // Skip incompatible module updates completely, otherwise test schema versions.
+ if (!update_check_incompatibility($module) && $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) {
+ $form['start'][$module] = array(
+ '#value' => t('%module module can not be updated. Its schema version is %schema_version. Updates up to and including %last_removed have been removed in this release. In order to update %module module, you will first <a href="@upgrade">need to upgrade</a> to the last version in which these updates were available.', array('%module' => $module, '%schema_version' => $schema_version, '%last_removed' => $last_removed, '@upgrade' => url('http://drupal.org/upgrade'))),
+ '#prefix' => '<div class="warning">',
+ '#suffix' => '</div>',
+ );
+ $form['start']['#collapsed'] = FALSE;
+ 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',
@@ -537,22 +550,9 @@ function update_create_batch_table() {
function update_fix_compatibility() {
$ret = array();
$incompatible = array();
- $themes = system_theme_data();
- $modules = module_rebuild_cache();
$query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
while ($result = db_fetch_object($query)) {
- $name = $result->name;
- $file = array();
- if ($result->type == 'module' && isset($modules[$name])) {
- $file = $modules[$name];
- }
- else if ($result->type == 'theme' && isset($themes[$name])) {
- $file = $themes[$name];
- }
- if (!isset($file)
- || !isset($file->info['core'])
- || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
- || version_compare(phpversion(), $file->info['php']) < 0) {
+ if (update_check_incompatibility($result->name, $result->type)) {
$incompatible[] = $name;
}
}
@@ -563,6 +563,33 @@ function update_fix_compatibility() {
}
/**
+ * Helper function to test compatibility of a module or theme.
+ */
+function update_check_incompatibility($name, $type = 'module') {
+ static $themes, $modules;
+
+ // Store values of expensive functions for future use.
+ if (empty($themes) || empty($modules)) {
+ $themes = system_theme_data();
+ $modules = module_rebuild_cache();
+ }
+
+ if ($type == 'module' && isset($modules[$name])) {
+ $file = $modules[$name];
+ }
+ else if ($type == 'theme' && isset($themes[$name])) {
+ $file = $themes[$name];
+ }
+ if (!isset($file)
+ || !isset($file->info['core'])
+ || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
+ || version_compare(phpversion(), $file->info['php']) < 0) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
* Perform Drupal 5.x to 6.x updates that are required for update.php
* to function properly.
*