diff -r'uNF^f' -x CVS drupal/includes/bootstrap.inc drupal.new/includes/bootstrap.inc --- drupal/includes/bootstrap.inc 2005-04-12 18:55:11.000000000 +0200 +++ drupal.new/includes/bootstrap.inc 2005-05-05 22:34:06.862945568 +0200 @@ -17,57 +17,6 @@ define('WATCHDOG_WARNING', 1); define('WATCHDOG_ERROR', 2); - -/** - * Locate the appropriate configuration file. - * - * Try finding a matching configuration directory by stripping the - * website's hostname from left to right and pathname from right to - * left. The first configuration file found will be used, the - * remaining will ignored. If no configuration file is found, - * return a default value '$confdir/default'. - * - * Example for a fictitious site installed at - * http://www.drupal.org/mysite/test/ the 'settings.php' is - * searched in the following directories: - * - * 1. $confdir/www.drupal.org.mysite.test - * 2. $confdir/drupal.org.mysite.test - * 3. $confdir/org.mysite.test - * - * 4. $confdir/www.drupal.org.mysite - * 5. $confdir/drupal.org.mysite - * 6. $confdir/org.mysite - * - * 7. $confdir/www.drupal.org - * 8. $confdir/drupal.org - * 9. $confdir/org - * - * 10. $confdir/default - */ -function conf_init() { - static $conf = ''; - - if ($conf) { - return $conf; - } - - $confdir = 'sites'; - $uri = explode('/', $_SERVER['PHP_SELF']); - $server = explode('.', rtrim($_SERVER['HTTP_HOST'], '.')); - for ($i = count($uri) - 1; $i > 0; $i--) { - for ($j = count($server); $j > 0; $j--) { - $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i)); - if (file_exists("$confdir/$dir/settings.php")) { - $conf = "$confdir/$dir"; - return $conf; - } - } - } - $conf = "$confdir/default"; - return $conf; -} - /** * Returns and optionally sets the filename for a system item (module, * theme, etc.). The filename, whether provided, cached, or retrieved @@ -690,15 +639,4 @@ function drupal_get_messages() { return $messages; } -unset($conf); -$config = conf_init(); - -include_once "$config/settings.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()); - ?> diff -r'uNF^f' -x CVS drupal/includes/common.inc drupal.new/includes/common.inc --- drupal/includes/common.inc 2005-05-05 11:07:08.000000000 +0200 +++ drupal.new/includes/common.inc 2005-05-05 22:34:06.870944352 +0200 @@ -1862,55 +1862,7 @@ function drupal_get_path($type, $name) { return dirname(drupal_get_filename($type, $name)); } -/** - * Provide a substitute clone() function for PHP4. - */ -if (version_compare(phpversion(), '5.0') < 0) { - eval(' - function clone($object) { - return $object; - } - '); +function drupal_clone($object) { + return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object); } - -// Set the Drupal custom error handler. -set_error_handler('error_handler'); - -include_once 'includes/theme.inc'; -include_once 'includes/pager.inc'; -include_once 'includes/menu.inc'; -include_once 'includes/tablesort.inc'; -include_once 'includes/file.inc'; -include_once 'includes/xmlrpc.inc'; -include_once 'includes/image.inc'; - -// Emit the correct charset HTTP header. -drupal_set_header('Content-Type: text/html; charset=utf-8'); - -// Initialize $_GET['q'] prior to loading modules and invoking hook_init(). -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 all enabled modules. -module_init(); - -if (!user_access('bypass input data check')) { - // We can't use $_REQUEST because it consists of the contents of $_POST, - // $_GET and $_COOKIE: if any of the input arrays share a key, only one - // value will be verified. - if (!valid_input_data($_GET) - || !valid_input_data($_POST) - || !valid_input_data($_COOKIE) - || !valid_input_data($_FILES)) { - die('Terminated request because of suspicious input data.'); - } -} - -// Initialize the localization system. -$locale = locale_initialize(); - ?> diff -r'uNF^f' -x CVS drupal/includes/database.inc drupal.new/includes/database.inc --- drupal/includes/database.inc 2005-04-08 16:24:03.000000000 +0200 +++ drupal.new/includes/database.inc 2005-05-05 22:34:06.871944200 +0200 @@ -279,7 +279,4 @@ function db_rewrite_sql($query, $primary * @} End of "defgroup database". */ -// Initialize the default database. -db_set_active(); - ?> diff -r'uNF^f' -x CVS drupal/includes/database.mysql.inc drupal.new/includes/database.mysql.inc --- drupal/includes/database.mysql.inc 2005-04-14 20:50:16.000000000 +0200 +++ drupal.new/includes/database.mysql.inc 2005-05-05 22:34:06.873943896 +0200 @@ -40,15 +40,20 @@ function db_connect($url) { function _db_query($query, $debug = 0) { global $active_db; global $queries; + static $dev_query; - if (variable_get('dev_query', 0)) { + if (!isset($dev_query)) { + $dev_query = function_exists('variable_get') ? variable_get('dev_query', 0) : $GLOBALS['dev_query']; + } + + if ($dev_query) { list($usec, $sec) = explode(' ', microtime()); $timer = (float)$usec + (float)$sec; } $result = mysql_query($query, $active_db); - if (variable_get('dev_query', 0)) { + if ($dev_query) { list($usec, $sec) = explode(' ', microtime()); $stop = (float)$usec + (float)$sec; $diff = $stop - $timer; diff -r'uNF^f' -x CVS drupal/includes/database.pgsql.inc drupal.new/includes/database.pgsql.inc --- drupal/includes/database.pgsql.inc 2005-04-08 13:24:46.000000000 +0200 +++ drupal.new/includes/database.pgsql.inc 2005-05-05 22:34:06.874943744 +0200 @@ -36,15 +36,21 @@ function db_connect($url) { function _db_query($query, $debug = 0) { global $active_db, $last_result; global $queries; + static $dev_query; - if (variable_get('dev_query', 0)) { + if (!isset($dev_query)) { + $dev_query = function_exists('variable_get') ? variable_get('dev_query', 0) : $GLOBALS['dev_query']; + } + + + if ($dev_query) { list($usec, $sec) = explode(' ', microtime()); $timer = (float)$usec + (float)$sec; } $last_result = pg_query($active_db, $query); - if (variable_get('dev_query', 0)) { + if ($dev_query) { list($usec, $sec) = explode(' ', microtime()); $stop = (float)$usec + (float)$sec; $diff = $stop - $timer; diff -r'uNF^f' -x CVS drupal/includes/init.inc drupal.new/includes/init.inc --- drupal/includes/init.inc 1970-01-01 01:00:00.000000000 +0100 +++ drupal.new/includes/init.inc 2005-05-05 23:01:31.192969408 +0200 @@ -0,0 +1,118 @@ + 0; $i--) { + for ($j = count($server); $j > 0; $j--) { + $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i)); + if (file_exists("$confdir/$dir/settings.php")) { + $conf = "$confdir/$dir"; + return $conf; + } + } + } + $conf = "$confdir/default"; + return $conf; +} + +function drupal_bootstrap($phase) { + static $done = -1; + + $phase = array_search($phase, array('database', 'bootstrap', 'session', 'common')); + if ($phase == FALSE) { + return; + } + + for (; $done <= $phase; $done++) { + _drupal_bootstrap($done); + } +} + +function _drupal_bootstrap($phase) { + switch ($phase) { + case 0: + global $conf; + unset($conf); + include_once conf_init() .'/settings.php'; + include_once 'includes/database.inc'; + // Initialize the default database. + db_set_active(); + break; + case 1: + include_once 'includes/bootstrap.inc'; + $conf = variable_init(isset($conf) ? $conf : array()); + case 2: + include_once conf_init() .'/settings_ini_set.php'; + include_once 'includes/session.inc'; + session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); + session_start(); + break; + case 3: + include_once 'includes/common.inc'; + // Set the Drupal custom error handler. + set_error_handler('error_handler'); + // Emit the correct charset HTTP header. + drupal_set_header('Content-Type: text/html; charset=utf-8'); + // Initialize $_GET['q'] prior to loading modules and invoking hook_init(). + 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 all enabled modules. + module_init(); + if (!user_access('bypass input data check')) { + // We can't use $_REQUEST because it consists of the contents of $_POST, + // $_GET and $_COOKIE: if any of the input arrays share a key, only one + // value will be verified. + if (!valid_input_data($_GET) + || !valid_input_data($_POST) + || !valid_input_data($_COOKIE) + || !valid_input_data($_FILES)) { + die('Terminated request because of suspicious input data.'); + } + } + // Initialize the localization system. + $locale = locale_initialize(); + break; + } +} + +?> \ No newline at end of file diff -r'uNF^f' -x CVS drupal/includes/session.inc drupal.new/includes/session.inc --- drupal/includes/session.inc 2005-04-11 21:05:52.000000000 +0200 +++ drupal.new/includes/session.inc 2005-05-05 22:34:06.875943592 +0200 @@ -6,9 +6,6 @@ * User session handling functions. */ -session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); -session_start(); - /*** Session functions *****************************************************/ function sess_open($save_path, $session_name) { diff -r'uNF^f' -x CVS drupal/includes/theme.inc drupal.new/includes/theme.inc --- drupal/includes/theme.inc 2005-05-05 09:35:57.000000000 +0200 +++ drupal.new/includes/theme.inc 2005-05-05 22:34:06.880942832 +0200 @@ -34,6 +34,7 @@ function init_theme() { global $user, $custom_theme, $theme_engine, $theme_key; + drupal_bootstrap('database'); $themes = list_themes(); // Only select the user selected theme if it is available in the diff -r'uNF^f' -x CVS drupal/index.php drupal.new/index.php --- drupal/index.php 2005-04-24 18:34:32.000000000 +0200 +++ drupal.new/index.php 2005-05-05 23:01:51.618864200 +0200 @@ -9,10 +9,18 @@ * prints the appropriate page. */ -include_once 'includes/bootstrap.inc'; +include_once 'includes/init.inc'; +include_once 'includes/module.inc'; +drupal_bootstrap('session'); drupal_page_header(); -include_once 'includes/common.inc'; - +drupal_bootstrap('common'); +include_once 'includes/theme.inc'; +include_once 'includes/pager.inc'; +include_once 'includes/menu.inc'; +include_once 'includes/tablesort.inc'; +include_once 'includes/file.inc'; +include_once 'includes/xmlrpc.inc'; +include_once 'includes/image.inc'; fix_gpc_magic(); $return = menu_execute_active_handler(); diff -r'uNF^f' -x CVS drupal/index.php.rej drupal.new/index.php.rej --- drupal/index.php.rej 1970-01-01 01:00:00.000000000 +0100 +++ drupal.new/index.php.rej 2005-05-05 22:34:06.861945720 +0200 @@ -0,0 +1,31 @@ +*************** +*** 9,18 **** + * prints the appropriate page. + */ + +- include_once 'includes/bootstrap.inc'; + drupal_page_header(); +- include_once 'includes/common.inc'; +- + fix_gpc_magic(); + + $return = menu_execute_active_handler(); +--- 9,26 ---- + * prints the appropriate page. + */ + ++ include_once 'includes/init.inc'; ++ include_once 'includes/module.inc'; ++ drupal_bootstrap('bootstrap'); + drupal_page_header(); ++ drupal_bootstrap('common'); ++ include_once 'includes/theme.inc'; ++ include_once 'includes/pager.inc'; ++ include_once 'includes/menu.inc'; ++ include_once 'includes/tablesort.inc'; ++ include_once 'includes/file.inc'; ++ include_once 'includes/xmlrpc.inc'; ++ include_once 'includes/image.inc'; + fix_gpc_magic(); + + $return = menu_execute_active_handler(); diff -r'uNF^f' -x CVS drupal/modules/node.module drupal.new/modules/node.module --- drupal/modules/node.module 2005-04-24 18:34:34.000000000 +0200 +++ drupal.new/modules/node.module 2005-05-05 22:59:54.988594696 +0200 @@ -1501,7 +1501,7 @@ function node_preview($node) { // Display a preview of the node: // Previewing alters $node so it needs to be cloned. - $output = theme('node_preview', clone($node)); + $output = theme('node_preview', drupal_clone($node)); $output .= node_form($node); diff -r'uNF^f' -x CVS drupal/sites/default/settings_ini_set.php drupal.new/sites/default/settings_ini_set.php --- drupal/sites/default/settings_ini_set.php 1970-01-01 01:00:00.000000000 +0100 +++ drupal.new/sites/default/settings_ini_set.php 2005-05-05 22:34:48.958546064 +0200 @@ -0,0 +1,23 @@ + \ No newline at end of file diff -r'uNF^f' -x CVS drupal/sites/default/settings.php drupal.new/sites/default/settings.php --- drupal/sites/default/settings.php 2005-04-14 20:34:31.000000000 +0200 +++ drupal.new/sites/default/settings.php 2005-05-05 22:33:40.888894224 +0200 @@ -35,11 +35,11 @@ /** * Database settings: * - * Note that the $db_url variable gets parsed using PHP's built-in + * Note that the $GLOBALS['db_url'] variable gets parsed using PHP's built-in * URL parser (i.e. using the "parse_url()" function) so make sure * not to confuse the parser. If your username, password * or database name contain characters used to delineate - * $db_url parts, you can escape them via URI hex encodings: + * $GLOBALS['db_url'] parts, you can escape them via URI hex encodings: * * : = %3a / = %2f @ = %40 * + = %2b ( = %28 ) = %29 @@ -47,25 +47,25 @@ * * To specify multiple connections to be used in your site (i.e. for * complex custom modules) you can also specify an associative array - * of $db_url variables with the 'default' element used until otherwise + * of $GLOBALS['db_url'] variables with the 'default' element used until otherwise * requested. * * You can optionally set prefixes for some or all database table names - * by using the $db_prefix setting. If a prefix is specified, the table + * by using the $GLOBALS['db_prefix'] setting. If a prefix is specified, the table * name will be prepended with its value. Be sure to use valid database * characters only, usually alphanumeric and underscore. If no prefixes * are desired, leave it as an empty string ''. * - * To have all database names prefixed, set $db_prefix as a string: + * To have all database names prefixed, set $GLOBALS['db_prefix'] as a string: * - * $db_prefix = 'main_'; + * $GLOBALS['db_prefix'] = 'main_'; * - * To provide prefixes for specific tables, set $db_prefix as an array. + * To provide prefixes for specific tables, set $GLOBALS['db_prefix'] as an array. * The array's keys are the table names and the values are the prefixes. * The 'default' element holds the prefix for any tables not specified * elsewhere in the array. Example: * - * $db_prefix = array( + * $GLOBALS['db_prefix'] = array( * 'default' => 'main_', * 'users' => 'shared_', * 'sessions' => 'shared_', @@ -75,11 +75,11 @@ * ); * * Database URL format: - * $db_url = 'mysql://username:password@localhost/database'; - * $db_url = 'pgsql://username:password@localhost/database'; + * $GLOBALS['db_url'] = 'mysql://username:password@localhost/database'; + * $GLOBALS['db_url'] = 'pgsql://username:password@localhost/database'; */ -$db_url = 'mysql://username:password@localhost/database'; -$db_prefix = ''; +$GLOBALS['db_url'] = 'mysql://username:password@localhost/database'; +$GLOBALS['db_prefix'] = ''; /** * Base URL: @@ -87,7 +87,7 @@ * The URL of your website's main page. It is not allowed to have * a trailing slash; Drupal will add it for you. */ -$base_url = 'http://localhost'; +$GLOBALS['base_url'] = 'http://localhost'; /** * PHP settings: @@ -119,7 +119,7 @@ * the default settings.php. Any configuration setting from the 'variable' * table can be given a new value. */ -//$conf = array( +//$GLOBALS['conf'] = array( // 'site_name' => 'My Drupal site', // 'theme_default' => 'pushbutton', // 'anonymous' => 'Visitor'