From d9d43eea27156f12e6a0b6fdbe9a5db774622574 Mon Sep 17 00:00:00 2001
From: Neil Drumm <drumm@3064.no-reply.drupal.org>
Date: Mon, 14 Aug 2006 05:47:36 +0000
Subject: [PATCH] #64212 by chx, dww, and Eaton, allow for branched updates.

---
 CHANGELOG.txt                 |  4 +++-
 modules/system/system.install | 22 ++++++++++++++++------
 update.php                    | 18 ++++++++++++++----
 3 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 403de60e7afc..bdd68d415950 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -40,7 +40,9 @@ Drupal x.x.x, xxxx-xx-xx (development version)
     * made it easier for node access modules to work well with each other.
     * added configurable content types.
     * changed node rendering to work with structured arrays.
-- removed the archive module
+- removed the archive module.
+- upgrade system:
+    * created space for update branches.
 
 Drupal 4.7.0, 2006-05-01
 ------------------------
diff --git a/modules/system/system.install b/modules/system/system.install
index c5b16583368a..5c52809fa2fa 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -2842,7 +2842,12 @@ function system_update_182() {
   return $ret;
 }
 
-function system_update_183() {
+/**
+ * @defgroup updates-4.7-to-x.x System updates from 4.7 to x.x
+ * @{
+ */
+
+function system_update_1000() {
   $ret = array();
   switch ($GLOBALS['db_type']) {
     case 'mysql':
@@ -2868,7 +2873,7 @@ function system_update_183() {
   return $ret;
 }
 
-function system_update_184() {
+function system_update_1001() {
   // change DB schema for better poll support
   $ret = array();
 
@@ -2887,7 +2892,7 @@ function system_update_184() {
   return $ret;
 }
 
-function system_update_185() {
+function system_update_1002() {
   // Make the forum's vocabulary the highest in list, if present
   $ret = array();
 
@@ -2898,7 +2903,7 @@ function system_update_185() {
   return $ret;
 }
 
-function system_update_186() {
+function system_update_1003() {
   // Make use of guid in feed items
   $ret = array();
   switch ($GLOBALS['db_type']) {
@@ -2914,7 +2919,7 @@ function system_update_186() {
 }
 
 
-function system_update_187() {
+function system_update_1004() {
   // Increase the size of bid in boxes and aid in access
   $ret = array();
   switch ($GLOBALS['db_type']) {
@@ -2930,7 +2935,7 @@ function system_update_187() {
   return $ret;
 }
 
-function system_update_188() {
+function system_update_1005() {
   // Add ability to create dynamic node types like the CCK module
   $ret = array();
 
@@ -3025,3 +3030,8 @@ function system_update_188() {
 
   return $ret;
 }
+
+/**
+ * @} End of "defgroup updates-4.7-to-x.x"
+ * The next series of updates should start at 2000.
+ */
diff --git a/update.php b/update.php
index 3713d2178fb8..039e882ac771 100644
--- a/update.php
+++ b/update.php
@@ -337,11 +337,18 @@ function update_selection_page() {
     if ($updates !== FALSE) {
       $updates = drupal_map_assoc($updates);
       $updates[] = 'No updates available';
+      $default = drupal_get_installed_schema_version($module);
+      foreach (array_keys($updates) as $update) {
+        if ($update > $default) {
+          $default = $update;
+          break;
+        }
+      }
 
       $form['start'][$module] = array(
         '#type' => 'select',
         '#title' => $module . ' module',
-        '#default_value' => array_search(drupal_get_installed_schema_version($module), $updates) + 1,
+        '#default_value' => $default,
         '#options' => $updates,
       );
     }
@@ -369,10 +376,13 @@ function update_update_page() {
   // Set the installed version so updates start at the correct place.
   foreach ($_POST['edit']['start'] as $module => $version) {
     drupal_set_installed_schema_version($module, $version - 1);
-    $max_version = max(drupal_get_schema_versions($module));
+    $updates = drupal_get_schema_versions($module);
+    $max_version = max($updates);
     if ($version <= $max_version) {
-      foreach (range($version, $max_version) as $update) {
-        $_SESSION['update_remaining'][] = array('module' => $module, 'version' => $update);
+      foreach ($updates as $update) {
+        if ($update >= $version) {
+          $_SESSION['update_remaining'][] = array('module' => $module, 'version' => $update);
+        }
       }
     }
   }
-- 
GitLab