Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2214: BLT doctor detect alias files. (#2221) #2365

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 41 additions & 54 deletions src/Drush/Command/BltDoctorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,49 +732,46 @@ protected function checkDrupalVm() {
else {
$this->setDrupalVmConfig();
}
if ($this->drushAliasesFileExists()) {
$local_alias_id = $this->config['drush']['aliases']['local'];
if ($local_alias_id !== 'self') {
if (empty($this->drushAliases[$local_alias_id])) {
$this->logOutcome(__FUNCTION__ . ":alias", [
"The drush alias assigned to drush.aliases.local does not exist in your drush aliases file.",
" drush.aliases.local is set to @$local_alias_id",
" Looked in " . $this->repoRoot . '/drush/site-aliases/aliases.drushrc.php',
$local_alias_id = '@' . $this->config['drush']['aliases']['local'];
if ($local_alias_id !== '@self') {
if (empty($this->drushAliases[$local_alias_id])) {
$this->logOutcome(__FUNCTION__ . ":alias", [
"The drush alias assigned to drush.aliases.local does not exist in your drush aliases file.",
" drush.aliases.local is set to @$local_alias_id",
], 'error');
$passed = FALSE;
}
else {
$this->logOutcome(__FUNCTION__ . ':alias', "drush.aliases.local exists your drush aliases file.", 'info');
$local_alias = $this->drushAliases[$local_alias_id];
if ('vagrant' != $_SERVER['USER'] && $local_alias['remote-host'] != $this->drupalVmConfig['vagrant_hostname']) {
$this->logOutcome(__FUNCTION__ . ":remote-host", [
"remote-host for @$local_alias_id drush alias does not match vagrant_hostname for DrupalVM.",
" remote-host is set to {$local_alias['remote-host']} for @$local_alias_id",
" vagrant_hostname is set to {$this->drupalVmConfig['vagrant_hostname']} for DrupalVM.",
" {$local_alias['remote-host']} != {$this->drupalVmConfig['vagrant_hostname']}",
], 'error');
$passed = FALSE;
}
else {
$this->logOutcome(__FUNCTION__ . ':alias', "drush.aliases.local exists your drush aliases file.", 'info');
$local_alias = $this->drushAliases[$local_alias_id];
if ('vagrant' != $_SERVER['USER'] && $local_alias['remote-host'] != $this->drupalVmConfig['vagrant_hostname']) {
$this->logOutcome(__FUNCTION__ . ":remote-host", [
"remote-host for @$local_alias_id drush alias does not match vagrant_hostname for DrupalVM.",
" remote-host is set to {$local_alias['remote-host']} for @$local_alias_id",
" vagrant_hostname is set to {$this->drupalVmConfig['vagrant_hostname']} for DrupalVM.",
" {$local_alias['remote-host']} != {$this->drupalVmConfig['vagrant_hostname']}",
], 'error');
$passed = FALSE;
}
$parsed_uri = parse_url($local_alias['uri']);
if ($parsed_uri['host'] != $this->drupalVmConfig['vagrant_hostname']) {
$this->logOutcome(__FUNCTION__ . ":uri", [
"uri for @$local_alias_id drush alias does not match vagrant_hostname for DrupalVM.",
" uri is set to {$local_alias['uri']} for @$local_alias_id",
" vagrant_hostname is set to {$this->drupalVmConfig['vagrant_hostname']} for DrupalVM.",
" {$local_alias['uri']} != {$this->drupalVmConfig['vagrant_hostname']}",
], 'error');
$passed = FALSE;
}
$expected_root = $this->drupalVmConfig['drupal_composer_install_dir'] . '/docroot';
if ($local_alias['root'] != $expected_root) {
$this->logOutcome(__FUNCTION__ . ":root", [
"root for @$local_alias_id drush alias does not match docroot for DrupalVM.",
" root is set to {$local_alias['root']} for @$local_alias_id",
" docroot is set to $expected_root for DrupalVM.",
" {$local_alias['root']} != $expected_root",
], 'error');
$passed = FALSE;
}
$parsed_uri = parse_url($local_alias['uri']);
if ($parsed_uri['host'] != $this->drupalVmConfig['vagrant_hostname']) {
$this->logOutcome(__FUNCTION__ . ":uri", [
"uri for @$local_alias_id drush alias does not match vagrant_hostname for DrupalVM.",
" uri is set to {$local_alias['uri']} for @$local_alias_id",
" vagrant_hostname is set to {$this->drupalVmConfig['vagrant_hostname']} for DrupalVM.",
" {$local_alias['uri']} != {$this->drupalVmConfig['vagrant_hostname']}",
], 'error');
$passed = FALSE;
}
$expected_root = $this->drupalVmConfig['drupal_composer_install_dir'] . '/docroot';
if ($local_alias['root'] != $expected_root) {
$this->logOutcome(__FUNCTION__ . ":root", [
"root for @$local_alias_id drush alias does not match docroot for DrupalVM.",
" root is set to {$local_alias['root']} for @$local_alias_id",
" docroot is set to $expected_root for DrupalVM.",
" {$local_alias['root']} != $expected_root",
], 'error');
$passed = FALSE;
}
}
}
Expand Down Expand Up @@ -804,28 +801,18 @@ protected function setDrupalVmConfig() {
return $this->drupalVmConfig;
}

/**
* @return mixed
*/
protected function drushAliasesFileExists() {
return file_exists($this->repoRoot . '/drush/site-aliases/aliases.drushrc.php');
}

/**
*
*/
protected function checkDrushAliases() {
$file_path = $this->repoRoot . '/drush/site-aliases/aliases.drushrc.php';
if (!$this->drushAliasesFileExists()) {
$return = drush_invoke_process(null, 'sa', null, array('format'=>'json'), array('integrate', FALSE));
if ($return['error_status']) {
$this->logOutcome(__FUNCTION__, [
"drush alias file does not exist!",
"",
"Create $file_path",
"Cannot find any valid drush aliases.",
], 'error');
}
else {
require $file_path;
$this->drushAliases = $aliases;
$this->drushAliases = $return['object'];
}
}

Expand Down