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

4.7.x
Dries Buytaert 2005-07-23 05:57:27 +00:00
parent 5fe4dd3221
commit ba1660168f
7 changed files with 27 additions and 19 deletions

View File

@ -7,7 +7,7 @@
*/ */
include_once 'includes/bootstrap.inc'; include_once 'includes/bootstrap.inc';
drupal_bootstrap('full'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// If not in 'safe mode', increase the maximum execution time: // If not in 'safe mode', increase the maximum execution time:
if (!ini_get('safe_mode')) { if (!ini_get('safe_mode')) {

View File

@ -17,6 +17,11 @@ define('WATCHDOG_NOTICE', 0);
define('WATCHDOG_WARNING', 1); define('WATCHDOG_WARNING', 1);
define('WATCHDOG_ERROR', 2); 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 * Start the timer with the specified name. If you start and stop
* the same timer multiple times, the measured intervals will be * 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 * previous one, so invoking a later phase automatically runs the earlier
* phases too. The most important usage is that if you want to access * phases too. The most important usage is that if you want to access
* Drupal database from a script without loading anything else, you can * 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 * @param $phase
* A string. Allowed values are: * A constant. Allowed values are:
* 'database': initialize database layer. * DRUPAL_BOOTSTRAP_DATABASE: initialize database layer.
* 'session': initialize session handling. * DRUPAL_BOOTSTRAP_SESSION: initialize session handling.
* 'page cache': load bootstrap.inc and module.inc, start the variable * DRUPAL_BOOTSTRAP_PAGE_CACHE: load bootstrap.inc and module.inc, start
* system and try to serve a page from the cache. * the variable system and try to serve a page from the cache.
* 'full': Drupal is fully loaded, validate and fix input data. * DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input
* data.
*/ */
function drupal_bootstrap($phase) { 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); _drupal_bootstrap($current_phase);
if ($phase == $current_phase) { if ($phase == $current_phase) {
return; return;
@ -819,7 +825,7 @@ function _drupal_bootstrap($phase) {
global $conf; global $conf;
switch ($phase) { switch ($phase) {
case 'database': case DRUPAL_BOOTSTRAP_DATABASE:
global $db_url, $db_prefix, $base_url; global $db_url, $db_prefix, $base_url;
$conf = array(); $conf = array();
require_once conf_init() .'/settings.php'; require_once conf_init() .'/settings.php';
@ -827,12 +833,14 @@ function _drupal_bootstrap($phase) {
// Initialize the default database. // Initialize the default database.
db_set_active(); db_set_active();
break; break;
case 'session':
case DRUPAL_BOOTSTRAP_SESSION:
require_once './includes/session.inc'; require_once './includes/session.inc';
session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
session_start(); session_start();
break; break;
case 'page cache':
case DRUPAL_BOOTSTRAP_PAGE_CACHE:
require_once './includes/module.inc'; require_once './includes/module.inc';
// Start a page timer: // Start a page timer:
timer_start('page'); timer_start('page');
@ -848,7 +856,8 @@ function _drupal_bootstrap($phase) {
$conf = variable_init(isset($conf) ? $conf : array()); $conf = variable_init(isset($conf) ? $conf : array());
drupal_page_header(); drupal_page_header();
break; break;
case 'full':
case DRUPAL_BOOTSTRAP_FULL:
require_once './includes/common.inc'; require_once './includes/common.inc';
_drupal_bootstrap_full(); _drupal_bootstrap_full();
break; break;

View File

@ -248,7 +248,6 @@ function _locale_import_po($file, $lang, $mode) {
} }
} }
// Successful import
// rebuild locale cache // rebuild locale cache
cache_clear_all("locale:$lang"); cache_clear_all("locale:$lang");

View File

@ -34,7 +34,7 @@ define('MARK_UPDATED', 2);
function init_theme() { function init_theme() {
global $user, $custom_theme, $theme_engine, $theme_key; global $user, $custom_theme, $theme_engine, $theme_key;
drupal_bootstrap('database'); drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
$themes = list_themes(); $themes = list_themes();
// Only select the user selected theme if it is available in the // Only select the user selected theme if it is available in the

View File

@ -10,7 +10,7 @@
*/ */
require_once './includes/bootstrap.inc'; require_once './includes/bootstrap.inc';
drupal_bootstrap('full'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$return = menu_execute_active_handler(); $return = menu_execute_active_handler();
switch ($return) { switch ($return) {

View File

@ -207,7 +207,7 @@ function update_info() {
if (isset($_GET["op"])) { if (isset($_GET["op"])) {
include_once "includes/bootstrap.inc"; include_once "includes/bootstrap.inc";
drupal_bootstrap('full'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Access check: // Access check:
if (($access_check == 0) || ($user->uid == 1)) { if (($access_check == 0) || ($user->uid == 1)) {

View File

@ -7,7 +7,7 @@
*/ */
include_once 'includes/bootstrap.inc'; include_once 'includes/bootstrap.inc';
drupal_bootstrap('full'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
include_once 'includes/xmlrpcs.inc'; include_once 'includes/xmlrpcs.inc';
xmlrpc_server(module_invoke_all('xmlrpc')); xmlrpc_server(module_invoke_all('xmlrpc'));