Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.177
diff -u -Ffunction -r1.177 update.php
--- update.php	3 Mar 2006 08:37:47 -0000	1.177
+++ update.php	4 Mar 2006 14:59:32 -0000
@@ -304,6 +304,9 @@ function update_data($module, $number) {
   if (!isset($_SESSION['update_results'][$module][$number])) {
     $_SESSION['update_results'][$module][$number] = array();
   }
+  if (!is_array($ret)) {
+    $ret = array();
+  }
   $_SESSION['update_results'][$module][$number] = array_merge($_SESSION['update_results'][$module][$number], $ret);
 
   if ($finished == 1) {
@@ -497,6 +500,10 @@ function update_finished_page($success) 
       foreach ($updates as $number => $queries) {
         $output .= '<h4>Update #'. $number .'</h4>';
         $output .= '<ul>';
+        if (!is_array($queries) || !count($queries)) {
+          $output .= '<li class="none">No queries</li></ul>';
+          continue;
+        }
         foreach ($queries as $query) {
           if ($query['success']) {
             $output .= '<li class="success">'. $query['query'] .'</li>';
@@ -505,9 +512,6 @@ function update_finished_page($success) 
             $output .= '<li class="failure"><strong>Failed:</strong> '. $query['query'] .'</li>';
           }
         }
-        if (!count($queries)) {
-          $output .= '<li class="none">No queries</li>';
-        }
         $output .= '</ul>';
       }
     }
@@ -543,7 +547,6 @@ function update_access_denied_page() {
 
 // This code may be removed later.  It is part of the Drupal 4.5 to 4.7 migration.
 function update_fix_system_table() {
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
   $row = db_fetch_object(db_query_range('SELECT * FROM {system}', 0, 1));
   if (!isset($row->weight)) {
     $ret = array();
@@ -636,11 +639,40 @@ function update_convert_table_utf8($tabl
   return $ret;
 }
 
+function update_get_db_server_version() {
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      if (function_exists('mysql_get_server_info')) {
+        // Since:  MySQL library: 4.0.1-alpha,  PHP: 4.0.5.
+        $version = mysql_get_server_info($GLOBALS['active_db']);
+      }
+      else {
+        $row = db_fetch_object(db_query('SELECT version() AS version'));
+        $version = $row->version;
+      }
+      return str_replace(array('-debug','-max','-nt','-opt'), '', $version);
+      break;
+    case 'pgsql':
+      /*
+       * Not using pg_version() because it is only available in PHP 5 and with
+       * PostgreSQL library: 7.4.  More importantly, the 'server_version'
+       * is missing, at least in PHP 5.1.2.
+       */
+      $row = db_fetch_object(db_query('SELECT version() AS version'));
+      return preg_replace('/^[^0-9]+([^ ]+).*/i', '\\1', $row->version);
+      break;
+  }
+  return 0;
+}
+
 // Some unavoidable errors happen because the database is not yet up to date.
 // We suppress them to avoid confusion. All errors are still logged.
 ini_set('display_errors', FALSE);
 
 include_once './includes/bootstrap.inc';
+drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
+$GLOBALS['db_server_version'] = update_get_db_server_version();
 update_fix_system_table();
 update_fix_access_table();
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
