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

PHP Fatal error: Uncaught TypeError thrown if invalid alias used #5208

Closed
cgmonroe opened this issue Aug 17, 2022 · 1 comment
Closed

PHP Fatal error: Uncaught TypeError thrown if invalid alias used #5208

cgmonroe opened this issue Aug 17, 2022 · 1 comment

Comments

@cgmonroe
Copy link

Describe the bug
If you enter an invalid/ undefined alias on a drush command, you do not get a "Unknown alias" or similar error. Instead you get a PHP Fatal error: with no other explanation.

To Reproduce
The command:

drush @xxx.xxx status

Returns the PhP Fatal errors.

Also happens if the group is valid but site name is wrong, e.g. drush @my-sites.wrong-alias status

Expected behavior
The expected behavior would be just a message like:

[preflight] The alias @xxx.xxx could not be found.

Actual behavior
The command returns this error stack trace.

PHP Fatal error: Uncaught TypeError: Return value of Drush\Preflight\PreflightSiteLocator::determineSelf() must be an instance of Consolidation\SiteAlias\SiteAlias, bool returned in /app/vendor/drush/drush/src/Preflight/PreflightSiteLocator.php:68
Stack trace:
#0 /app/vendor/drush/drush/src/Preflight/PreflightSiteLocator.php(39): Drush\Preflight\PreflightSiteLocator->determineSelf(Object(Drush\Preflight\PreflightArgs), Object(Drush\Config\Environment), '/app/docroot')
#1 /app/vendor/drush/drush/src/Preflight/Preflight.php(286): Drush\Preflight\PreflightSiteLocator->findSite(Object(Drush\Preflight\PreflightArgs), Object(Drush\Config\Environment), '/app/docroot')
#2 /app/vendor/drush/drush/src/Runtime/Runtime.php(69): Drush\Preflight\Preflight->preflight(Array)
#3 /app/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#5 /app/vendor/drush/drush/drush(3): require('/ in /app/vendor/drush/drush/src/Preflight/PreflightSiteLocator.php on line 68

Fatal error: Uncaught TypeError: Return value of Drush\Preflight\PreflightSiteLocator::determineSelf() must be an instance of Consolidation\SiteAlias\SiteAlias, bool returned in /app/vendor/drush/drush/src/Preflight/PreflightSiteLocator.php:68
Stack trace:
#0 /app/vendor/drush/drush/src/Preflight/PreflightSiteLocator.php(39): Drush\Preflight\PreflightSiteLocator->determineSelf(Object(Drush\Preflight\PreflightArgs), Object(Drush\Config\Environment), '/app/docroot')
#1 /app/vendor/drush/drush/src/Preflight/Preflight.php(286): Drush\Preflight\PreflightSiteLocator->findSite(Object(Drush\Preflight\PreflightArgs), Object(Drush\Config\Environment), '/app/docroot')
#2 /app/vendor/drush/drush/src/Runtime/Runtime.php(69): Drush\Preflight\Preflight->preflight(Array)
#3 /app/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#5 /app/vendor/drush/drush/drush(3): require('/ in /app/vendor/drush/drush/src/Preflight/PreflightSiteLocator.php on line 68

Workaround
Drop back to Drush 10.

System Configuration

Q A
Drush version? 11.1.1
Drupal version? 9.4.5
PHP version 7.4
OS? Mac using Lando drupal9 setup. / Also tested in Acquia server shell - same result

Additional information
None.

@weitzman
Copy link
Member

Fixed in #5239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants