amazeeio / drupal-integrations

Add this project to any Drupal distribution based on drupal/core-composer-scaffold to enable it for use on Lagoon.
https://packagist.org/packages/amazeeio/drupal_integrations
1 stars 4 forks source link

package doesn't exit safely in non-lagoon environment #22

Open tobybellwood opened 10 months ago

tobybellwood commented 10 months ago

When used outside of a Lagoon environment, the drupal_integrations package may throw an error like the below:

Fatal error: Uncaught Error: Call to undefined method Drush\Drush::bootstrapManager() in /mnt/www/html/samplesite/drush/Commands/contrib/drupal_integrations/src/LagoonCommands.php:176
Stack trace:
#0 /mnt/www/html/samplesite/drush/Commands/contrib/drupal_integrations/src/LagoonCommands.php(67): Drush\Commands\drupal_integrations\LagoonCommands->getLagoonYml()
#1 /usr/local/drush8/vendor/drush/drush/includes/annotationcommand_adapter.inc(322): Drush\Commands\drupal_integrations\LagoonCommands->__construct()
#2 /usr/local/drush8/vendor/drush/drush/includes/annotationcommand_adapter.inc(297): annotationcommand_adapter_create_commandfile_instance()
#3 /usr/local/drush8/vendor/drush/drush/includes/annotationcommand_adapter.inc(109): annotationcommand_adapter_get_commands()
#4 /usr/local/drush8/vendor/drush/drush/includes/command.inc(1132): annotationcommand_adapter_commands()
#5 /usr/local/drush8/vendor/drush/drush/includes/command.inc(1430): drush_get_commands()
#6 /usr/local/drush8/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(54): drush_parse_command()
#7 /usr/local/drush8/vendor/drush/drush/includes/preflight.inc(67): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 /usr/local/drush8/vendor/drush/drush/drush.php(12): drush_main()
#9 {main}
  thrown in /mnt/www/html/samplesite/drush/Commands/contrib/drupal_integrations/src/LagoonCommands.php on line 176
Drush command terminated abnormally due to an unrecoverable error.       [error]

We suspect this is because Drush, in trying to get it's internal commands in order is hitting the _construct of this package and the getLagoonYml function should probably be skipped in a non-Lagoon env to failsafe. We can probably wrap it in a LAGOON env check like we do for settings.php (https://github.com/amazeeio/drupal-integrations/blob/main/assets/settings.lagoon.php#L33)

skyred commented 10 months ago

PR https://github.com/amazeeio/drupal-integrations/pull/23