From 7f5caaacdca6de4876ee876a9d1de5ce97ea0c93 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Fri, 1 Oct 2010 19:52:28 +0000 Subject: #915216 by catch, Damien Tournoud: Fixing update.php cannot apply updates error. --- includes/module.inc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'includes') diff --git a/includes/module.inc b/includes/module.inc index 71b6a5551..82319054e 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -404,8 +404,19 @@ function module_enable($module_list, $enable_dependencies = TRUE) { // Now install the module if necessary. if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) { drupal_install_schema($module); + + // Set the schema version to the number of the last update provided + // by the module. $versions = drupal_get_schema_versions($module); - drupal_set_installed_schema_version($module, $versions ? max($versions) : SCHEMA_INSTALLED); + $version = $versions ? max($versions) : SCHEMA_INSTALLED; + + // If the module has no current updates, but has some that were + // previously removed, set the version to the value of + // hook_update_last_removed(). + if ($last_removed = module_invoke($module, 'update_last_removed')) { + $version = max($version, $last_removed); + } + drupal_set_installed_schema_version($module, $version); // Allow the module to perform install tasks. module_invoke($module, 'install'); // Record the fact that it was installed. -- cgit v1.2.3