function _drush_bootstrap_drush_validate

6.x bootstrap.inc _drush_bootstrap_drush_validate()
3.x environment.inc _drush_bootstrap_drush_validate()
4.x environment.inc _drush_bootstrap_drush_validate()
5.x bootstrap.inc _drush_bootstrap_drush_validate()

Validate initial Drush bootstrap phase.

File

includes/environment.inc, line 327
Functions used by drush to query the environment and setting the current configuration.

Code

function _drush_bootstrap_drush_validate() {
  // Test safe mode is off.
  if (ini_get('safe_mode')) {
    return drush_bootstrap_error('DRUSH_SAFE_MODE', dt('PHP safe mode is activated. Drush requires that safe mode is disabled.'));
  }

  // try using the PEAR installed version of Console_Table
  $tablefile = 'Console/Table.php';
  if (@file_get_contents($tablefile, FILE_USE_INCLUDE_PATH) === FALSE) {
    $tablefile = DRUSH_BASE_PATH . '/includes/table.inc';

    // Attempt to download Console Table, via various methods.
    if (!file_exists($tablefile)) {
      $targetpath = dirname($tablefile);
      // not point continuing if we can't write to the target path
      if (!is_writable($targetpath)) {
        return drush_bootstrap_error('DRUSH_TABLES_INC', dt("Drush needs a copy of the PEAR Console_Table library in order to function, and the attempt to download this file automatically failed because you do not have permission to write files in !path. To continue you will need to download the !version package from http://pear.php.net/package/Console_Table, extract it, and copy the Table.php file into Drush's directory as !tablefile.", array('!path' => $targetpath, '!version' => DRUSH_TABLE_VERSION, '!tablefile' => $tablefile)));
      }

      if ($file = @file_get_contents(DRUSH_TABLE_URL)) {
        @file_put_contents($tablefile, $file);
      }
      if (!file_exists($tablefile)) {
        drush_shell_exec("wget -q --timeout=30 -O $tablefile " . DRUSH_TABLE_URL);
        if (!file_exists($tablefile)) {
          drush_shell_exec("curl -s  --connect-timeout 30 -o $tablefile " . DRUSH_TABLE_URL);
          if (!file_exists($tablefile)) {
            return drush_bootstrap_error('DRUSH_TABLES_INC', dt("Drush needs a copy of the PEAR Console_Table library in order to function, and the attempt to download this file automatically failed. To continue you will need to download the !version package from http://pear.php.net/package/Console_Table, extract it, and copy the Table.php file into Drush's directory as !tablefile.", array('!version' => DRUSH_TABLE_VERSION, '!tablefile' => $tablefile)));
          }
        }
      }
    }
  }
  require_once $tablefile;

  return TRUE;
}