function drush_bootstrap

8.0.x bootstrap.inc drush_bootstrap($phase, $phase_max = FALSE)
6.x bootstrap.inc drush_bootstrap($phase, $phase_max = FALSE)
7.x bootstrap.inc drush_bootstrap($phase, $phase_max = FALSE)
3.x environment.inc drush_bootstrap($phase)
4.x environment.inc drush_bootstrap($phase, $phase_max = FALSE)
5.x bootstrap.inc drush_bootstrap($phase, $phase_max = FALSE)
master bootstrap.inc drush_bootstrap($phase, $phase_max = FALSE)

Bootstrap Drush to the desired phase.

This function will sequentially bootstrap each lower phase up to the phase that has been requested.

Parameters

phase: The bootstrap phase to bootstrap to. @see \Drush\Boot::bootstrap_phases

10 calls to drush_bootstrap()
drush_bootstrap_max in includes/bootstrap.inc
Bootstrap to the highest level possible, without triggering any errors.
drush_bootstrap_to_phase in includes/bootstrap.inc
Bootstrap to the specified phase.
drush_browse in commands/core/browse.drush.inc
Command callback.
drush_core_pre_site_install in commands/core/site_install.drush.inc
Perform setup tasks for installation.
drush_core_site_install_version in commands/core/drupal/site_install_6.inc
Install Drupal 6.x

... See full list

File

includes/bootstrap.inc, line 309

Code

function drush_bootstrap($phase, $phase_max = FALSE) {
  $bootstrap = drush_get_bootstrap_object();
  $phases = _drush_bootstrap_phases(TRUE);
  $result = TRUE;

  // If the requested phase does not exist in the list of available
  // phases, it means that the command requires bootstrap to a certain
  // level, but no site root could be found.
  if (!isset($phases[$phase])) {
    $result = drush_bootstrap_error('DRUSH_NO_SITE', dt("We could not find an applicable site for that command."));
  }

  // Once we start bootstrapping past the DRUSH_BOOTSTRAP_DRUSH phase, we
  // will latch the bootstrap object, and prevent it from changing.
  if ($phase > DRUSH_BOOTSTRAP_DRUSH) {
    drush_latch_bootstrap_object($bootstrap);
  }

  drush_set_context('DRUSH_BOOTSTRAPPING', TRUE);
  foreach ($phases as $phase_index => $current_phase) {
    $bootstrapped_phase = drush_get_context('DRUSH_BOOTSTRAP_PHASE', -1);
    if ($phase_index > $phase) {
      break;
    }
    if ($phase_index > $bootstrapped_phase) {
      if ($result = drush_bootstrap_validate($phase_index)) {
        if (method_exists($bootstrap, $current_phase) && !drush_get_error()) {
          drush_log(dt("Drush bootstrap phase : !function()", array('!function' => $current_phase)), LogLevel::BOOTSTRAP);
          $bootstrap->{$current_phase}();

          // Reset commandfile cache and find any new command files that are available during this bootstrap phase.
          drush_get_commands(TRUE);
          _drush_find_commandfiles($phase_index, $phase_max);
        }
        drush_set_context('DRUSH_BOOTSTRAP_PHASE', $phase_index);
      }
    }
  }
  drush_set_context('DRUSH_BOOTSTRAPPING', FALSE);
  if (!$result || drush_get_error()) {
    $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', array());
    foreach ($errors as $code => $message) {
      drush_set_error($code, $message);
    }
  }
  return !drush_get_error();
}