From ba1660168f2843d263e6205e6b03591c4ba98af1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 23 Jul 2005 05:57:27 +0000 Subject: - Patch #27003 by Neil: use named constants instead of strings --- cron.php | 2 +- includes/bootstrap.inc | 35 ++++++++++++++++++++++------------- includes/locale.inc | 1 - includes/theme.inc | 2 +- index.php | 2 +- update.php | 2 +- xmlrpc.php | 2 +- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/cron.php b/cron.php index 51afe406b..7b4ca4a64 100644 --- a/cron.php +++ b/cron.php @@ -7,7 +7,7 @@ */ include_once 'includes/bootstrap.inc'; -drupal_bootstrap('full'); +drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // If not in 'safe mode', increase the maximum execution time: if (!ini_get('safe_mode')) { diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 4db35b208..fe85eb447 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -17,6 +17,11 @@ define('WATCHDOG_NOTICE', 0); define('WATCHDOG_WARNING', 1); define('WATCHDOG_ERROR', 2); +define('DRUPAL_BOOTSTRAP_DATABASE', 0); +define('DRUPAL_BOOTSTRAP_SESSION', 1); +define('DRUPAL_BOOTSTRAP_PAGE_CACHE', 2); +define('DRUPAL_BOOTSTRAP_FULL', 3); + /** * Start the timer with the specified name. If you start and stop * the same timer multiple times, the measured intervals will be @@ -794,20 +799,21 @@ function drupal_is_denied($type, $mask) { * previous one, so invoking a later phase automatically runs the earlier * phases too. The most important usage is that if you want to access * Drupal database from a script without loading anything else, you can - * include bootstrap.inc, and call drupal_bootstrap('database'). + * include bootstrap.inc, and call drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE). * * @param $phase - * A string. Allowed values are: - * 'database': initialize database layer. - * 'session': initialize session handling. - * 'page cache': load bootstrap.inc and module.inc, start the variable - * system and try to serve a page from the cache. - * 'full': Drupal is fully loaded, validate and fix input data. + * A constant. Allowed values are: + * DRUPAL_BOOTSTRAP_DATABASE: initialize database layer. + * DRUPAL_BOOTSTRAP_SESSION: initialize session handling. + * DRUPAL_BOOTSTRAP_PAGE_CACHE: load bootstrap.inc and module.inc, start + * the variable system and try to serve a page from the cache. + * DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input + * data. */ function drupal_bootstrap($phase) { - static $phases = array('database', 'session', 'page cache', 'full'); + static $phases = array(DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_PAGE_CACHE, DRUPAL_BOOTSTRAP_FULL); - while ($current_phase = array_shift($phases)) { + while (!is_null($current_phase = array_shift($phases))) { _drupal_bootstrap($current_phase); if ($phase == $current_phase) { return; @@ -819,7 +825,7 @@ function _drupal_bootstrap($phase) { global $conf; switch ($phase) { - case 'database': + case DRUPAL_BOOTSTRAP_DATABASE: global $db_url, $db_prefix, $base_url; $conf = array(); require_once conf_init() .'/settings.php'; @@ -827,12 +833,14 @@ function _drupal_bootstrap($phase) { // Initialize the default database. db_set_active(); break; - case 'session': + + case DRUPAL_BOOTSTRAP_SESSION: require_once './includes/session.inc'; session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); session_start(); break; - case 'page cache': + + case DRUPAL_BOOTSTRAP_PAGE_CACHE: require_once './includes/module.inc'; // Start a page timer: timer_start('page'); @@ -848,7 +856,8 @@ function _drupal_bootstrap($phase) { $conf = variable_init(isset($conf) ? $conf : array()); drupal_page_header(); break; - case 'full': + + case DRUPAL_BOOTSTRAP_FULL: require_once './includes/common.inc'; _drupal_bootstrap_full(); break; diff --git a/includes/locale.inc b/includes/locale.inc index fbc9ca16f..e464619b3 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -248,7 +248,6 @@ function _locale_import_po($file, $lang, $mode) { } } - // Successful import // rebuild locale cache cache_clear_all("locale:$lang"); diff --git a/includes/theme.inc b/includes/theme.inc index 730446743..02f74fd36 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -34,7 +34,7 @@ define('MARK_UPDATED', 2); function init_theme() { global $user, $custom_theme, $theme_engine, $theme_key; - drupal_bootstrap('database'); + drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); $themes = list_themes(); // Only select the user selected theme if it is available in the diff --git a/index.php b/index.php index 6816599b8..afe3d9cd5 100644 --- a/index.php +++ b/index.php @@ -10,7 +10,7 @@ */ require_once './includes/bootstrap.inc'; -drupal_bootstrap('full'); +drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $return = menu_execute_active_handler(); switch ($return) { diff --git a/update.php b/update.php index 90eace13b..bb13fc862 100644 --- a/update.php +++ b/update.php @@ -207,7 +207,7 @@ function update_info() { if (isset($_GET["op"])) { include_once "includes/bootstrap.inc"; - drupal_bootstrap('full'); + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // Access check: if (($access_check == 0) || ($user->uid == 1)) { diff --git a/xmlrpc.php b/xmlrpc.php index 408f44062..3cfc87493 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -7,7 +7,7 @@ */ include_once 'includes/bootstrap.inc'; -drupal_bootstrap('full'); +drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); include_once 'includes/xmlrpcs.inc'; xmlrpc_server(module_invoke_all('xmlrpc')); -- cgit v1.2.3