1 bootstrap.inc _backdrop_bootstrap_configuration()

Sets up the script environment and loads settings.php.

File

core/includes/bootstrap.inc, line 3021
Functions that need to be loaded on every Backdrop request.

Code

function _backdrop_bootstrap_configuration() {
  backdrop_environment_initialize();

  // Start a page timer:
  timer_start('page');
  // Initialize the configuration, including variables from settings.php.
  backdrop_settings_initialize();
  // Sanitize input from $_GET, $_POST, etc.
  _backdrop_bootstrap_sanitize_request();

  // Set the Backdrop custom error handler.
  set_error_handler('_backdrop_error_handler');
  set_exception_handler('_backdrop_exception_handler');

  // Load configuration classes and functions.
  require_once BACKDROP_ROOT . '/core/includes/config.inc';

  // Redirect the user to the installation script if Backdrop has not been
  // installed yet (i.e., if no $databases array has been defined in the
  // settings.php file) and we are not already installing.
  if (empty($GLOBALS['databases']) && !backdrop_installation_attempted()) {
    include_once BACKDROP_ROOT . '/core/includes/install.inc';
    install_goto('core/install.php');
  }

  // Untrusted host names, throw an exception for the end-user.
  if (!defined('MAINTENANCE_MODE') && !backdrop_check_trusted_hosts($_SERVER['HTTP_HOST'])) {
    throw new Exception(format_string('The HTTP Host "@hostname" is not white-listed for this site. Check the trusted_host_patterns setting in settings.php.', array('@hostname' => $_SERVER['HTTP_HOST'])));
  }

  // Bootstrap the database if it is needed but not yet available.
  $config_storage = config_get_config_storage('active');

  // Check that the config directory is not empty.
  if (!defined('MAINTENANCE_MODE') && (!empty($config_storage))) {
    if (!($config_storage->exists('system.core') || $config_storage->exists('system.performance'))) {
      if (is_a($config_storage, 'ConfigFileStorage')) {
        $directory = config_get_config_directory('active');
        $exception_message = "The configuration directory in settings.php is specified as '$directory', but this directory is either empty or missing crucial files. Check that the \$config_directories variable is correct in settings.php.";
      }
      else {
        $exception_message = "The active configuration location is either empty or missing crucial information. Check that the \$settings['config_active_class'] variable is correct in settings.php.";
      }
      throw new Exception($exception_message);
    }
  }
}