Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.264
diff -u -p -r1.264 update.php
--- update.php	24 Oct 2008 18:47:02 -0000	1.264
+++ update.php	26 Oct 2008 19:16:16 -0000
@@ -330,7 +330,7 @@ function update_finished($success, $resu
   $_SESSION['update_results'] = $results;
   $_SESSION['update_success'] = $success;
   $_SESSION['updates_remaining'] = $operations;
-  
+
   // Now that the update is done, we can disable site maintenance if it was
   // previously turned off.
   if (isset($_SESSION['site_offline']) && $_SESSION['site_offline'] == FALSE) {
@@ -574,6 +574,37 @@ function update_fix_d6_requirements() {
 }
 
 /**
+ * Users who still have a Drupal 6 database (and are in the process of
+ * updating to Drupal 7) need extra help before a full bootstrap can be
+ * achieved. This function does the necessary preliminary work that allows
+ * the bootstrap to be successful.
+ *
+ * No access check has been performed when this function is called, so no
+ * changes to the database should be made here.
+ */
+function update_prepare_d7_bootstrap() {
+  // Allow the database system to work even though the registry has not
+  // been created yet.
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
+  include_once DRUPAL_ROOT . '/includes/install.inc';
+  drupal_install_init_database();
+  spl_autoload_unregister('drupal_autoload_class');
+  spl_autoload_unregister('drupal_autoload_interface');
+  // The new {blocked_ips} table is used in Drupal 7 to store a list of
+  // banned IP addresses. If this table doesn't exist then we are still
+  // running on a Drupal 6 database, so suppress the unavoidable errors
+  // that occur.
+  try {
+    drupal_bootstrap(DRUPAL_BOOTSTRAP_ACCESS);
+  }
+  catch (Exception $e) {
+    if (db_table_exists('blocked_ips')) {
+      throw $e;
+    }
+  }
+}
+
+/**
  * Add the update task list to the current page.
  */
 function update_task_list($active = NULL) {
@@ -655,13 +686,10 @@ if (empty($op)) {
   install_goto('update.php?op=info');
 }
 
+update_prepare_d7_bootstrap();
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 drupal_maintenance_theme();
 
-// This must happen *after* drupal_bootstrap(), since it calls
-// variable_(get|set), which only works after a full bootstrap.
-update_create_batch_table();
-
 // Turn error reporting back on. From now on, only fatal errors (which are
 // not passed through the error handler) will cause a message to be printed.
 ini_set('display_errors', TRUE);
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.242
diff -u -p -r1.242 bootstrap.inc
--- includes/bootstrap.inc	25 Oct 2008 01:13:40 -0000	1.242
+++ includes/bootstrap.inc	26 Oct 2008 19:16:17 -0000
@@ -393,7 +393,7 @@ function conf_init() {
   global $base_url, $base_path, $base_root;
 
   // Export the following settings.php variables to the global namespace
-  global $databases, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
+  global $databases, $db_prefix, $db_url, $cookie_domain, $conf, $installed_profile, $update_free_access;
   $conf = array();
 
   if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.811
diff -u -p -r1.811 common.inc
--- includes/common.inc	26 Oct 2008 18:06:38 -0000	1.811
+++ includes/common.inc	26 Oct 2008 19:16:17 -0000
@@ -682,7 +682,7 @@ function _drupal_log_error($type, $messa
     drupal_set_message(t('@type: %message in %function (line %line of %file).', array('@type' => $type, '%message' => $message, '%function' => $caller['function'], '%line' => $caller['line'], '%file' => $caller['file'])), 'error');
   }
 
-  watchdog('php', '%type: %message in %function (line %line of %file).', array('%type' => $type, '%message' => $message, '%function' => $caller['function'], '%file' => $caller['file'], '%line' => $caller['line']), WATCHDOG_ERROR);  
+  watchdog('php', '%type: %message in %function (line %line of %file).', array('%type' => $type, '%message' => $message, '%function' => $caller['function'], '%file' => $caller['file'], '%line' => $caller['line']), WATCHDOG_ERROR);
 
   if ($fatal) {
     drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' Service unavailable');
@@ -691,7 +691,7 @@ function _drupal_log_error($type, $messa
       print theme('page', t('The website encountered an unexpected error. Please try again later.'), FALSE);
     }
     else {
-      print theme('maintenance_page', t('The website encountered an unexpected error. Please try again later.'), FALSE);      
+      print theme('maintenance_page', t('The website encountered an unexpected error. Please try again later.'), FALSE);
     }
     exit;
   }
@@ -2137,7 +2137,7 @@ function drupal_add_js($data = NULL, $op
     'type' => 'module',
     // Default to a header scope only if we're adding some data.
     'scope' => isset($data) ? 'header' : NULL,
-    'cache' => TRUE, 
+    'cache' => TRUE,
     'defer' => FALSE,
     'preprocess' => TRUE
   );
@@ -2839,7 +2839,7 @@ function drupal_system_listing($mask, $d
 
 /**
  * Hands off structured Drupal arrays to type-specific *_alter implementations.
- * 
+ *
  * This dispatch function hands off structured Drupal arrays to type-specific
  * *_alter implementations. It ensures a consistent interface for all altering
  * operations.
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.446
diff -u -p -r1.446 theme.inc
--- includes/theme.inc	26 Oct 2008 18:06:38 -0000	1.446
+++ includes/theme.inc	26 Oct 2008 19:16:17 -0000
@@ -898,7 +898,7 @@ function theme_get_settings($key = NULL)
     'toggle_logo'                   =>  1,
     'toggle_favicon'                =>  1,
     'toggle_name'                   =>  1,
-    'toggle_search'                 =>  1,
+    'toggle_search'                 =>  0,
     'toggle_slogan'                 =>  0,
     'toggle_mission'                =>  1,
     'toggle_node_user_picture'      =>  0,
@@ -919,8 +919,8 @@ function theme_get_settings($key = NULL)
   }
 
   // Only offer search box if search.module is enabled.
-  if (!module_exists('search') || !user_access('search content')) {
-    $settings['toggle_search'] = 0;
+  if (!defined('MAINTENANCE_MODE') && module_exists('search') && user_access('search content')) {
+    $settings['toggle_search'] = 1;
   }
 
   return $settings;
Index: includes/database/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/database.inc,v
retrieving revision 1.16
diff -u -p -r1.16 database.inc
--- includes/database/database.inc	25 Oct 2008 02:03:54 -0000	1.16
+++ includes/database/database.inc	26 Oct 2008 19:16:18 -0000
@@ -410,9 +410,7 @@ abstract class DatabaseConnection extend
       }
     }
     catch (PDOException $e) {
-      if (!function_exists('module_implements')) {
-        _db_need_install();
-      }
+      _db_check_install_needed();
       if ($options['throw_exception']) {
         if ($query instanceof DatabaseStatement) {
           $query_string = $stmt->queryString;
@@ -886,13 +884,16 @@ abstract class Database {
    * Process the configuration file for database information.
    */
   final protected static function parseConnectionInfo() {
-    global $databases;
+    global $databases, $db_url;
 
-    if (empty($databases)) {
-      _db_need_install();
+    // Process database information from pre-Drupal 7 configuration files.
+    if (empty($databases) && !empty($db_url)) {
+      $databases = _db_parse_url($db_url);
     }
-    $databaseInfo = $databases;
 
+    _db_check_install_needed();
+
+    $databaseInfo = $databases;
     foreach ($databaseInfo as $index => $info) {
       foreach ($databaseInfo[$index] as $target => $value) {
         // If there is no "driver" property, then we assume it's an array of
@@ -1012,7 +1013,7 @@ abstract class Database {
       // It is extremely rare that an exception will be generated here other
       // than when installing.  We therefore intercept it and try the installer,
       // passing on the exception otherwise.
-      _db_need_install();
+      _db_check_install_needed();
       throw $e;
     }
   }
@@ -2014,14 +2015,45 @@ function db_result(DatabaseStatement $st
   return $statement->fetchField();
 }
 
-function _db_need_install() {
-  if (!function_exists('install_goto')) {
+/**
+ * Redirect the user to the installation script if Drupal has not been
+ * installed yet (i.e., if no $databases array has been defined in the
+ * settings file) and we are not already there. Otherwise, do nothing.
+ */
+function _db_check_install_needed() {
+  global $databases;
+  if (empty($databases) && !function_exists('install_main')) {
     include_once DRUPAL_ROOT . '/includes/install.inc';
     install_goto('install.php');
   }
 }
 
 /**
+ * Parse database connection URLs (in the old, pre-Drupal 7 format) and
+ * return them as an array of database connection information.
+ */
+function _db_parse_url($db_url) {
+  $databases = array();
+  if (!is_array($db_url)) {
+    $db_url = array('default' => $db_url);
+  }
+  foreach ($db_url as $database => $url) {
+    $url = parse_url($url);
+    $databases[$database]['default'] = array(
+      // MySQLi uses the mysql driver.
+      'driver' => $url['scheme'] == 'mysqli' ? 'mysql' : $url['scheme'],
+      // Remove the leading slash to get the database name.
+      'database' => substr(urldecode($url['path']), 1),
+      'username' => urldecode($url['user']),
+      'password' => isset($url['pass']) ? urldecode($url['pass']) : '',
+      'host' => urldecode($url['host']),
+      'port' => isset($url['port']) ? urldecode($url['port']) : '',
+    );
+  }
+  return $databases;
+}
+
+/**
  * Backward-compatibility utility.
  *
  * This function should be removed after all queries have been converted
Index: includes/database/pgsql/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/database.inc,v
retrieving revision 1.4
diff -u -p -r1.4 database.inc
--- includes/database/pgsql/database.inc	25 Oct 2008 02:12:35 -0000	1.4
+++ includes/database/pgsql/database.inc	26 Oct 2008 19:16:18 -0000
@@ -58,10 +58,7 @@ class DatabaseConnection_pgsql extends D
       }
     }
     catch (PDOException $e) {
-      if (!function_exists('module_implements')) {
-        _db_need_install();
-      }
-      //watchdog('database', var_export($e, TRUE) . $e->getMessage(), NULL, WATCHDOG_ERROR);
+      _db_check_install_needed();
       if ($options['throw_exception']) {
         if ($query instanceof DatabaseStatement) {
           $query_string = $stmt->queryString;
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.989
diff -u -p -r1.989 node.module
--- modules/node/node.module	25 Oct 2008 00:23:03 -0000	1.989
+++ modules/node/node.module	26 Oct 2008 19:16:18 -0000
@@ -591,8 +591,9 @@ function _node_types_build() {
   while ($type_object = db_fetch_object($type_result)) {
     // Check for node types from disabled modules and mark their types for removal.
     // Types defined by the node module in the database (rather than by a separate
-    // module using hook_node_info) have a base value of 'node_content'.
-    if ($type_object->base != 'node_content' && empty($info_array[$type_object->type])) {
+    // module using hook_node_info) have a base value of 'node_content'. The isset()
+    // check prevents errors on old (pre-Drupal 7) databases.
+    if (isset($type_object->base) && $type_object->base != 'node_content' && empty($info_array[$type_object->type])) {
       $type_object->disabled = TRUE;
     }
     if (!isset($_node_types[$type_object->type]) || $type_object->modified) {
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.272
diff -u -p -r1.272 system.install
--- modules/system/system.install	13 Oct 2008 20:29:42 -0000	1.272
+++ modules/system/system.install	26 Oct 2008 19:16:18 -0000
@@ -3042,8 +3042,8 @@ function system_update_7009() {
  */
 function system_update_7010() {
   $ret = array();
-  db_change_field($ret, 'menu_router', 'load_functions', 'load_functions', array('type' => 'text', 'not null' => TRUE, 'default' => ''));
-  db_change_field($ret, 'menu_router', 'to_arg_functions', 'to_arg_functions', array('type' => 'text', 'not null' => TRUE, 'default' => '',));
+  db_change_field($ret, 'menu_router', 'load_functions', 'load_functions', array('type' => 'text', 'not null' => TRUE));
+  db_change_field($ret, 'menu_router', 'to_arg_functions', 'to_arg_functions', array('type' => 'text', 'not null' => TRUE));
 
   return $ret;
 }
