X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FPreflight%2FPreflight.php;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FPreflight%2FPreflight.php;h=513a884f9684c0fd1fb2720cb19b775d97717325;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=e7b6d2ea97a43d9e30765167f593203245d54595;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/vendor/drush/drush/src/Preflight/Preflight.php b/vendor/drush/drush/src/Preflight/Preflight.php index e7b6d2ea9..513a884f9 100644 --- a/vendor/drush/drush/src/Preflight/Preflight.php +++ b/vendor/drush/drush/src/Preflight/Preflight.php @@ -4,7 +4,7 @@ namespace Drush\Preflight; use Drush\Config\Environment; use Drush\Config\ConfigLocator; use Drush\Config\EnvironmentConfigLoader; -use Drush\SiteAlias\SiteAliasManager; +use Consolidation\SiteAlias\SiteAliasManager; use DrupalFinder\DrupalFinder; /** @@ -255,16 +255,26 @@ class Preflight $paths = $this->configLocator->getSiteAliasPaths($this->preflightArgs->aliasPaths(), $this->environment); // Configure alias manager. - $this->aliasManager = (new SiteAliasManager())->addSearchLocations($paths); + $aliasFileLoader = new \Drush\SiteAlias\SiteAliasFileLoader(); + $this->aliasManager = (new SiteAliasManager($aliasFileLoader))->addSearchLocations($paths); $this->aliasManager->setReferenceData($config->export()); + + // Find the local site $siteLocator = new PreflightSiteLocator($this->aliasManager); $selfAliasRecord = $siteLocator->findSite($this->preflightArgs, $this->environment, $root); - $this->aliasManager->setSelf($selfAliasRecord); - $this->configLocator->addAliasConfig($selfAliasRecord->exportConfig()); - // Process the selected alias. This might change the selected site, - // so we will add new site-wide config location for the new root. - $root = $this->setSelectedSite($selfAliasRecord->localRoot()); + // If we did not find a local site, then we are destined to fail + // UNLESS RedispatchToSiteLocal::redispatchIfSiteLocalDrush takes over. + // Before we try to redispatch to the site-local Drush, though, we must + // initiaze the alias manager & c. based on any alias record we did find. + if ($selfAliasRecord) { + $this->aliasManager->setSelf($selfAliasRecord); + $this->configLocator->addAliasConfig($selfAliasRecord->exportConfig()); + + // Process the selected alias. This might change the selected site, + // so we will add new site-wide config location for the new root. + $root = $this->setSelectedSite($selfAliasRecord->localRoot()); + } // Now that we have our final Drupal root, check to see if there is // a site-local Drush. If there is, we will redispatch to it. @@ -275,6 +285,19 @@ class Preflight return $status; } + // If the site locator couldn't find a local site, and we did not + // redispatch to a site-local Drush, then we cannot continue. + // This can happen when using Drush 9 to call a site-local Drush 8 + // using an alias record that is only defined in a Drush 8 format. + if (!$selfAliasRecord) { + // Note that PreflightSiteLocator::findSite only returns 'false' + // when preflightArgs->alias() returns an alias name. In all other + // instances we will get an alias record, even if it is only a + // placeholder 'self' with the root holding the cwd. + $aliasName = $this->preflightArgs->alias(); + throw new \Exception("The alias $aliasName could not be found."); + } + // If we did not redispatch, then add the site-wide config for the // new root (if the root did in fact change) and continue. $this->configLocator->addSitewideConfig($root);