function drush_bootstrap_validate

8.0.x drush_bootstrap_validate($phase)
6.x drush_bootstrap_validate($phase)
7.x drush_bootstrap_validate($phase)
3.x drush_bootstrap_validate($phase)
4.x drush_bootstrap_validate($phase)
5.x drush_bootstrap_validate($phase)
master 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.


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

Return value

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

3 calls to drush_bootstrap_validate()
drush_bootstrap in includes/
Bootstrap Drush to the desired phase.
drush_bootstrap_max in includes/
Bootstrap to the highest level possible, without triggering any errors.
drush_bootstrap_to_phase in includes/
Bootstrap to the specified phase.


includes/, line 395


function drush_bootstrap_validate($phase) {
  $bootstrap = drush_get_bootstrap_object();
  $phases = _drush_bootstrap_phases(TRUE);
  static $result_cache = array();

  if (!array_key_exists($phase, $result_cache)) {
    drush_set_context('DRUSH_BOOTSTRAP_ERRORS', array());
    drush_set_context('DRUSH_BOOTSTRAP_VALUES', array());

    foreach ($phases as $phase_index => $current_phase) {
      $validated_phase = drush_get_context('DRUSH_BOOTSTRAP_VALIDATION_PHASE', -1);
      if ($phase_index > $phase) {
      if ($phase_index > $validated_phase) {
        $current_phase .= '_validate';
        if (method_exists($bootstrap, $current_phase)) {
          $result_cache[$phase_index] = $bootstrap->{$current_phase}();
        else {
          $result_cache[$phase_index] = TRUE;
        drush_set_context('DRUSH_BOOTSTRAP_VALIDATION_PHASE', $phase_index);
  return $result_cache[$phase];