webflo / drupal-finder

GNU General Public License v2.0
126 stars 25 forks source link

Recent deploy causes PHP Fatal Error #67

Open tbutterf opened 2 months ago

tbutterf commented 2 months ago

The Drastically simplify using Composer Runtime API commit deployed to the master branch on May 8, 2024 is causing problems on Drupal 10 sites with Drush version 2.4.3. Composer builds properly, but when I try to run a Drush command, such as a cache-rebuild, I get the following error:

PHP Fatal error:  Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php:153
Stack trace:
#0 /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php(153): is_link(Object(Drush\Config\Environment))
#1 /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php(75): DrupalFinder\DrupalFinder->discoverRoots(Object(Drush\Config\Environment))
#2 /var/www/html/vendor/drush/drush/src/Preflight/Preflight.php(310): DrupalFinder\DrupalFinder->__construct(Object(Drush\Config\Environment))
#3 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(58): Drush\Preflight\Preflight->preflight(Array)
#4 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run(Array)
#6 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
#7 /var/www/html/vendor/bin/drush(119): include('/var/www/html/v...')
#8 {main}
  thrown in /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php on line 153
tbutterf commented 2 months ago

It looks like updating Drush to the latest supported version solves this issue.

tbutterf commented 2 months ago

However, sometimes updating Drush to the latest isn't possible or advisable. If a site is on Drupal 9, it can't run the latest (12.x) Drush version, since Drupal 9 uses the 11.x branch of Drush.

FraserThompson commented 2 months ago

We were experiencing this with Drush 12.4.3 and updating to the latest 12.x (12.5.2) fixed it. However as noted above, Drush 12.x isn't compatible with Drupal 9, so this workaround won't work for Drupal <10.

tbutterf commented 2 months ago

I did some more testing in Drupal 9 with Drush 11.x, and it looks like Drush 11.x isn't affected by this issue. So, maybe nothing needs to be done?