? .directory ? drupal-496184.patch ? includes/.directory Index: includes/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/Attic/database.inc,v retrieving revision 1.92.2.9 diff -u -p -r1.92.2.9 database.inc --- includes/database.inc 1 Feb 2010 16:32:10 -0000 1.92.2.9 +++ includes/database.inc 17 Jun 2010 22:37:30 -0000 @@ -118,10 +118,12 @@ function db_prefix_tables($sql) { * @param $name * The name assigned to the newly active database connection. If omitted, the * default connection will be made active. + * @param $abort + * If database connection could not be made, should we abort here or continue. * * @return the name of the previously active database or FALSE if non was found. */ -function db_set_active($name = 'default') { +function db_set_active($name = 'default', $abort = TRUE) { global $db_url, $db_type, $active_db; static $db_conns, $active_name = FALSE; @@ -149,7 +151,21 @@ function db_set_active($name = 'default' _db_error_page("The database type '". $db_type ."' is unsupported. Please use either 'mysql' or 'mysqli' for MySQL, or 'pgsql' for PostgreSQL databases."); } - $db_conns[$name] = db_connect($connect_url); + $connection = db_connect($connect_url); + if (is_array($connection)) { + if ($connection[0]) { + $db_conns[$name] = $connection[1]; + } + elseif ($abort) { + _db_error_page($connection[1]); + } + else { + return FALSE; + } + } + else { + $db_conns[$name] = $connection; + } } $previous_name = $active_name; @@ -392,7 +408,7 @@ function db_rewrite_sql($query, $primary * Adds the DISTINCT flag to the supplied query if a DISTINCT doesn't already * exist in the query. Returns the altered query. * - * This will not, and never did guarantee that you will obtain distinct + * This will not, and never did guarantee that you will obtain distinct * values of $table.$field. * * @param $table Unused. Kept to remain API compatibility. Index: includes/database.mysql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/Attic/database.mysql.inc,v retrieving revision 1.89.2.2 diff -u -p -r1.89.2.2 database.mysql.inc --- includes/database.mysql.inc 1 Feb 2010 16:32:10 -0000 1.89.2.2 +++ includes/database.mysql.inc 17 Jun 2010 22:37:30 -0000 @@ -77,12 +77,12 @@ function db_connect($url) { $connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2); if (!$connection || !mysql_select_db(substr($url['path'], 1))) { // Show error screen otherwise - _db_error_page(mysql_error()); + return array(FALSE, mysql_error()); } // Force UTF-8. mysql_query('SET NAMES "utf8"', $connection); - return $connection; + return array(TRUE, $connection); } /** Index: includes/database.mysqli.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/Attic/database.mysqli.inc,v retrieving revision 1.54.2.2 diff -u -p -r1.54.2.2 database.mysqli.inc --- includes/database.mysqli.inc 1 Feb 2010 16:32:10 -0000 1.54.2.2 +++ includes/database.mysqli.inc 17 Jun 2010 22:37:30 -0000 @@ -76,13 +76,13 @@ function db_connect($url) { @mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $url['port'], NULL, MYSQLI_CLIENT_FOUND_ROWS); if (mysqli_connect_errno() > 0) { - _db_error_page(mysqli_connect_error()); + return array(FALSE, mysqli_connect_error()); } // Force UTF-8. mysqli_query($connection, 'SET NAMES "utf8"'); - return $connection; + return array(TRUE, $connection); } /** Index: includes/database.pgsql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/Attic/database.pgsql.inc,v retrieving revision 1.68.2.9 diff -u -p -r1.68.2.9 database.pgsql.inc --- includes/database.pgsql.inc 28 May 2010 15:02:16 -0000 1.68.2.9 +++ includes/database.pgsql.inc 17 Jun 2010 22:37:34 -0000 @@ -79,14 +79,14 @@ function db_connect($url) { $connection = @pg_connect($conn_string); if (!$connection) { require_once './includes/unicode.inc'; - _db_error_page(decode_entities($php_errormsg)); + return array(FALSE, decode_entities($php_errormsg)); } // Restore error tracking setting ini_set('track_errors', $track_errors_previous); pg_query($connection, "set client_encoding=\"UTF8\""); - return $connection; + return array(TRUE, $connection); } /**