Commit ba166016 authored by Dries's avatar Dries

- Patch #27003 by Neil: use named constants instead of strings

parent 5fe4dd32
......@@ -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')) {
......
......@@ -17,6 +17,11 @@
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;
......
......@@ -248,7 +248,6 @@ function _locale_import_po($file, $lang, $mode) {
}
}
// Successful import
// rebuild locale cache
cache_clear_all("locale:$lang");
......
......@@ -34,7 +34,7 @@
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
......
......@@ -10,7 +10,7 @@
*/
require_once './includes/bootstrap.inc';
drupal_bootstrap('full');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$return = menu_execute_active_handler();
switch ($return) {
......
......@@ -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)) {
......
......@@ -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'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment