You are here

function drupal_bootstrap in Drupal 4

Same name and namespace in other branches
  1. 5 includes/bootstrap.inc \drupal_bootstrap()
  2. 6 includes/bootstrap.inc \drupal_bootstrap()
  3. 7 includes/bootstrap.inc \drupal_bootstrap()

A string describing a phase of Drupal to load. Each phase adds to the 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(DRUPAL_BOOTSTRAP_DATABASE).

Parameters

$phase: 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.

6 calls to drupal_bootstrap()
cron.php in ./cron.php
index.php in ./index.php
init_theme in includes/theme.inc
Initialize the theme system by loading the theme.
statistics_exit in modules/statistics.module
Implementation of hook_exit().
update_fix_system_table in ./update.php

... See full list

File

includes/bootstrap.inc, line 778
Functions that need to be loaded on every Drupal request.

Code

function drupal_bootstrap($phase) {
  static $phases = array(
    DRUPAL_BOOTSTRAP_DATABASE,
    DRUPAL_BOOTSTRAP_SESSION,
    DRUPAL_BOOTSTRAP_PAGE_CACHE,
    DRUPAL_BOOTSTRAP_PATH,
    DRUPAL_BOOTSTRAP_FULL,
  );
  while (!is_null($current_phase = array_shift($phases))) {
    _drupal_bootstrap($current_phase);
    if ($phase == $current_phase) {
      return;
    }
  }
}