Index: index.php =================================================================== RCS file: /cvs/drupal/drupal/index.php,v retrieving revision 1.77 diff -u -r1.77 index.php --- index.php 16 Dec 2003 21:06:33 -0000 1.77 +++ index.php 29 Jan 2004 08:27:16 -0000 @@ -2,20 +2,25 @@ // $Id: index.php,v 1.77 2003/12/16 21:06:33 dries Exp $ include_once "includes/bootstrap.inc"; -drupal_page_header(); include_once "includes/common.inc"; -fix_gpc_magic(); +drupal_init(ATTEMP_DB); -menu_build("system"); -if (menu_active_handler_exists()) { - menu_execute_active_handler(); -} -else { - drupal_not_found(); -} +if (database_connected()) { + drupal_page_header(); + + fix_gpc_magic(); -drupal_page_footer(); + menu_build("system"); + + if (menu_active_handler_exists()) { + menu_execute_active_handler(); + } + else { + drupal_not_found(); + } + drupal_page_footer(); +} ?> Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.9 diff -u -r1.9 bootstrap.inc --- includes/bootstrap.inc 26 Jan 2004 19:05:20 -0000 1.9 +++ includes/bootstrap.inc 29 Jan 2004 08:27:20 -0000 @@ -236,11 +236,25 @@ unset($conf); $config = conf_init(); +define('ATTEMPT_DB', 1); +define('AVOID_DB', 0); + + include_once "includes/$config.php"; include_once "includes/database.inc"; include_once "includes/session.inc"; include_once "includes/module.inc"; -// initialize configuration variables, using values from conf.php if available: -$conf = variable_init(isset($conf) ? $conf : array()); +function bootstrap_init($init_db = ATTEMPT_DB) { + global $conf; + + if ($init_db) { + database_init(); + } + if (database_connected()) { + // initialize configuration variables, using values from conf.php if available: + $conf = variable_init(isset($conf) ? $conf : array()); + } + +} ?> Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.316 diff -u -r1.316 common.inc --- includes/common.inc 27 Jan 2004 22:10:47 -0000 1.316 +++ includes/common.inc 29 Jan 2004 08:27:24 -0000 @@ -1123,33 +1123,50 @@ include_once "includes/tablesort.inc"; include_once "includes/file.inc"; -// set error handler: -set_error_handler("error_handler"); - -// spit out the correct charset http header -header("Content-Type: text/html; charset=utf-8"); - -// initialize the _GET["q"] prior to loading the modules and invoking their 'init' hook: -if (!empty($_GET["q"])) { - $_GET["q"] = drupal_get_normal_path(trim($_GET["q"], "/")); -} -else { - $_GET["q"] = drupal_get_normal_path(variable_get("site_frontpage", "node")); +if (database_connected()) { + // set error handler: + set_error_handler("error_handler"); } -// initialize installed modules: -module_init(); +function drupal_init($db_init = ATTEMPT_DB) { + global $theme, $locale; -if ($_REQUEST && !user_access("bypass input data check")) { - if (!valid_input_data($_REQUEST)) { - die("terminated request because of suspicious input data"); + bootstrap_init($db_init); + + if (database_connected()) { + session_start(); } -} -// initialize localization system: -$locale = locale_init(); -// initialize theme: -$theme = init_theme(); + // spit out the correct charset http header + header("Content-Type: text/html; charset=utf-8"); + + + + if (database_connected()) { + // initialize the _GET["q"] prior to loading the modules and invoking their 'init' hook: + if (!empty($_GET["q"])) { + $_GET["q"] = drupal_get_normal_path(trim($_GET["q"], "/")); + } + else { + $_GET["q"] = drupal_get_normal_path(variable_get("site_frontpage", "node")); + } + + // initialize installed modules: + module_init(); + + if ($_REQUEST && !user_access("bypass input data check")) { + if (!valid_input_data($_REQUEST)) { + die("terminated request because of suspicious input data"); + } + } + + // initialize localization system: + $locale = locale_init(); + + // initialize theme: + $theme = init_theme(); + } +} ?> Index: includes/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.inc,v retrieving revision 1.27 diff -u -r1.27 database.inc --- includes/database.inc 1 Oct 2003 05:18:02 -0000 1.27 +++ includes/database.inc 29 Jan 2004 08:27:24 -0000 @@ -27,7 +27,14 @@ include_once "includes/database.pear.inc"; } -db_connect($db_url); +function database_init() { + global $db_success,$db_url; + $db_success = db_connect($db_url); +} +function database_connected() { + global $db_success; + return $db_success; +} ?> Index: includes/database.mysql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.mysql.inc,v retrieving revision 1.21 diff -u -r1.21 database.mysql.inc --- includes/database.mysql.inc 8 Dec 2003 06:32:18 -0000 1.21 +++ includes/database.mysql.inc 29 Jan 2004 08:27:25 -0000 @@ -9,9 +9,6 @@ $url["host"] = $url["host"] . ":" . $url["port"]; } - mysql_connect($url["host"], $url["user"], $url["pass"]) or die(mysql_error()); - mysql_select_db(substr($url["path"], 1)) or die("unable to select database"); - /* ** Note that you can change the 'mysql_connect' statement to 'mysql_pconnect' ** if you want to use persistent connections. This is not recommended on @@ -19,6 +16,15 @@ ** increases performance when the overhead to connect to your database is ** high (eg. your database and webserver live on different machines). */ + + $result = false; + $db_connect = mysql_connect($url["host"], $url["user"], $url["pass"]); + $table_select = mysql_select_db(substr($url["path"], 1)); + if ($db_connect && $table_select) { + $result = true; + } + + return $result; } /** Index: includes/session.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/session.inc,v retrieving revision 1.6 diff -u -r1.6 session.inc --- includes/session.inc 17 Jan 2004 10:06:04 -0000 1.6 +++ includes/session.inc 29 Jan 2004 08:27:25 -0000 @@ -2,7 +2,6 @@ // $Id: session.inc,v 1.6 2004/01/17 10:06:04 dries Exp $ session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); -session_start(); /*** Session functions *****************************************************/