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

Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /tmp/site/vendor/webflo/drupal-finder/src/DrupalFinder.php:153 #756

Closed
DEVDESAGAR1 opened this issue May 9, 2024 · 22 comments
Labels
bug Something isn't working

Comments

@DEVDESAGAR1
Copy link

Bug report

Phpstan is failing due to code updated in the webflo : https://github.com/webflo/drupal-finder/pull/65/files
Phpstan is using the this module
error :
Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /tmp/site/vendor/webflo/drupal-finder/src/DrupalFinder.php:153

Code snippet that reproduces the problem

@DEVDESAGAR1 DEVDESAGAR1 added the bug Something isn't working label May 9, 2024
@DEVDESAGAR1
Copy link
Author

Hello team,

I have created the pR for the fix : #757

@mglaman
Copy link
Owner

mglaman commented May 9, 2024

Oh, it dropped as a minor release. Okay, thanks for reporting and the PR

@mglaman
Copy link
Owner

mglaman commented May 10, 2024

@DEVDESAGAR1 I'm curious what configuration you have? I'm not seeing it error this way, nor are the Drupal.org GitLab CI jobs

@mglaman
Copy link
Owner

mglaman commented May 10, 2024

I can't reproduce the failures, but for now I'm merging #758 to accept the deprecations

@ahsanra
Copy link

ahsanra commented May 13, 2024

I am facing this exact same issue where i just upgrading Drupal 10.1.14 to latest Drupal 10.2.6.

I can not run Drush updb and get the following error which is same as you guys are facing, whats the fix so far we have? Really blocked at this point on this 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

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
Failed to run drush updb -y: exit status 255`

Screenshot 2024-05-13 at 10 11 56 AM

@ahsanra
Copy link

ahsanra commented May 13, 2024

This was Drush issue and i have solved it by creating a patch for Drush 12.

I was running into this issue when I upgraded to Drush 11.x to 12.x on a Drupal 10.1.x and 10.2.x

Found the issue fix on drush github create a patch and apply it to 12.x version from here: https://github.com/drush-ops/drush/pull/5755/files

Note: This issue is fixed and merged in Drush 13.x as per pull request conversation drush-ops/drush#5755

@liquidcms
Copy link

I am not sure what i updated that is now causing this error:

Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in E:\www\mysite\vendor\webflo\drupal-finder\src\DrupalFinder.php:153

but drush 12.5 and this patch: https://patch-diff.githubusercontent.com/raw/drush-ops/drush/pull/5755.patch does not fix it.

@liquidcms
Copy link

Ah, i had 12.5.0 (and the patch); but require drush 12.5.2 (maybe 12.5.1 would work) and the patch to fix.

@ahsanra
Copy link

ahsanra commented May 15, 2024

I have drush 12.5.2 and the patch works.

Try to update drush to the version and let me know.

@matthiasm11
Copy link

Drush 12.5.1 + patch does not work.
Drush 12.5.2 + patch does work, thanks!

@mglaman
Copy link
Owner

mglaman commented May 16, 2024

So, is this not an issue with phpstan-drupal? I'm guessing not, since the CI is passing for build integrations

@ahsanra
Copy link

ahsanra commented May 17, 2024

@mglaman True, but there is a retro effect somewhere so you will have to tie it up with drush 12.5.1+

@mglaman
Copy link
Owner

mglaman commented May 17, 2024

Understood, but it's not caused by this package. Just both share this same dependency

@mglaman mglaman closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@giuseppe-esposito-87
Copy link

I had the same problem with Drush 12.4.3, it works 12.5.2 even without the patch.

@LOBsTerr
Copy link

LOBsTerr commented May 29, 2024

I am using drush 12.5.2
When I use proposed patch : #757

I got this error:

RuntimeException thrown in /home/lob/www/fut/vendor/mglaman/phpstan-drupal/src/Drupal/DrupalAutoloader.php on line 109 while loading bootstrap file /home/lob/www/fut/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: Unable to detect Drupal in /home/lob/www/fut/web

@LOBsTerr
Copy link

I missed the part related to drush patch. So, to fix all issues, you need this patch: https://github.com/drush-ops/drush/pull/5755/files

@kevinquillen
Copy link

Updating to Drush 12.5.2 fixed this issue for me.

@rf033
Copy link

rf033 commented May 29, 2024

Updating to 12.5.2 fixed the issue. No patch needed.

@gwolf
Copy link

gwolf commented Jun 4, 2024

I just updated my sites, and am being bitten by this problem.

Updating to 12.5.2 does not fix the issue for me. I tried patching Drupal with https://github.com/drush-ops/drush/pull/5755/files, to no avail.

FWIW, I don't understand why this is triggering, as my document root is not a symlink. My files directory (web/sites/default/files) is a symlink, though.

@Manish-Sharma1995
Copy link

Faced same issue on upgrading from Drupal 10.2.4 to 10.3.0

Updating Drush to 12.5.2 fixed the issue for me. No patch needed. Thanks!

@therobyouknow
Copy link

Thank you @rf033 - your comment:#756 (comment) worked in my case.

2 ways to update drush:

  1. On my local personal dev environment set up, using ddev, I updated drush by doing:
ddev composer require drush/drush
robdaviswork@192 ligc-staging % ddev composer require drush/drush
./composer.json has been updated
Running composer update drush/drush
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading drush/drush (12.5.1 => 12.5.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Downloading drush/drush (12.5.2)
  - Upgrading drush/drush (12.5.1 => 12.5.2): Extracting archive
Generating autoload files
51 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found.
Using version ^12.5 for drush/drush

I now no longer get errors if doing ddev drush cr or ddev drush updb

  1. on my server / and generally for the codebase I would do:
composer require drush/drush

@blitke
Copy link

blitke commented Jul 8, 2024

Updating Drush to 12.5.2 fixed the issue for me. No patch needed.

@mglaman mglaman closed this as completed Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.