function drush_bootstrap_validate

8.0.x bootstrap.inc drush_bootstrap_validate($phase)
6.x bootstrap.inc drush_bootstrap_validate($phase)
7.x bootstrap.inc drush_bootstrap_validate($phase)
3.x environment.inc drush_bootstrap_validate($phase)
4.x environment.inc drush_bootstrap_validate($phase)
5.x bootstrap.inc drush_bootstrap_validate($phase)
master bootstrap.inc drush_bootstrap_validate($phase)

Validate whether a bootstrap phase can be reached.

This function will validate the settings that will be used during the actual bootstrap process, and allow commands to progressively bootstrap to the highest level that can be reached.

This function will only run the validation function once, and store the result from that execution in a local static. This avoids validating phases multiple times.

Parameters

phase: The bootstrap phase to validate to. Any of the following constants : DRUSH_BOOTSTRAP_DRUSH = Only Drush. DRUSH_BOOTSTRAP_DRUPAL_ROOT = Find a valid Drupal root. DRUSH_BOOTSTRAP_DRUPAL_SITE = Find a valid Drupal site. DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION = Load the site's settings. DRUSH_BOOTSTRAP_DRUPAL_DATABASE = Initialize the database. DRUSH_BOOTSTRAP_DRUPAL_FULL = Initialize Drupal fully. DRUSH_BOOTSTRAP_DRUPAL_LOGIN = Log into Drupal with a valid user.

Return value

True if bootstrap is possible, False if the validation failed.

3 calls to drush_bootstrap_validate()
drush_bootstrap in includes/bootstrap.inc
Bootstrap Drush to the desired phase.
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.

File

includes/bootstrap.inc, line 251
Drush bootstrapping code.

Code

function drush_bootstrap_validate($phase) {
  static $phases;
  static $result_cache = array();
  if (!$phases) {
    $phases = _drush_bootstrap_phases(TRUE);
  }
  static $phase_index = 0;
  // Check to see if anyone has changed --root or --uri
  _drush_bootstrap_select_drupal_site();
  if (!array_key_exists($phase, $result_cache)) {
    drush_set_context('DRUSH_BOOTSTRAP_ERRORS', array());
    drush_set_context('DRUSH_BOOTSTRAP_VALUES', array());

    while ($phase >= $phase_index && isset($phases[$phase_index])) {
      $current_phase = $phases[$phase_index] . '_validate';
      if (function_exists($current_phase)) {
        $result_cache[$phase_index] = $current_phase();
      }
      else {
        $result_cache[$phase_index] = TRUE;
      }
      drush_set_context('DRUSH_BOOTSTRAP_VALIDATION_PHASE', $phase_index);
      unset($phases[$phase_index++]);
    }
  }
  return $result_cache[$phase];
}