Problem/Motivation

When project_browser is enabled on the Drupal 10 site & any drush operation is executed apart from drush cr, a fatal error is thrown & the command gets terminated abnormally.

PHP Fatal error: Type of Drupal\project_browser\Commands\UpdateFixtureCommands::$logger must be ?Psr\Log\LoggerInterface (as in class Drush\Commands\DrushCommands) in /var/www/html/modules/contrib/project_browser/src/Commands/UpdateFixtureCommands.php on line 25

Steps to reproduce

Once vanilla Drupal 10 is installed, execute the following commands:
composer require 'drupal/project_browser:1.0.x-dev@dev'
composer require drush/drush

By this time, drush works normally, such as drush uli, drush cst

Now enable the project_browser module and try executing drush uli, it would throw the following error:

PHP Fatal error:  Type of Drupal\project_browser\Commands\UpdateFixtureCommands::$logger must be ?Psr\Log\LoggerInterface (as in class Drush\Commands\DrushCommands) in /var/www/html/modules/contrib/project_browser/src/Commands/UpdateFixtureCommands.php on line 25

Proposed resolution

The issue is happening due to the signature of the \Drush\Commands\DrushCommands::logger, which was updated last year in Dec, please see bd0cfe46c309383028b7fd994d2590cdbaaadcba

Remaining tasks

Create MR

  • ✅ File an issue about this project
  • ☐ Manual Testing
  • ☐ Code Review
  • ☐ Accessibility Review
  • ☐ Automated tests needed/written?

CommentFileSizeAuthor
#8 screenshot-drush-success-3292395.png10.38 KBcapysara
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Rishi Kulshreshtha created an issue. See original summary.

rishi.kulshreshtha’s picture

Assigned: rishi.kulshreshtha » Unassigned
Status: Active » Needs review
narendrar’s picture

Status: Needs review » Needs work

Great catch, but I think this change will not work for Drupal 9. We need a solution which works for both.

rishi.kulshreshtha’s picture

Status: Needs work » Needs review

So my initial thought was to provide a fix for D10 & then backport it to D9, but while revamping the code, I found that it isn't required. The code is now updated to replace the \Drupal\project_browser\Commands\UpdateFixtureCommands::$logger with inherited \Drush\Commands\DrushCommands::logger

narendrar’s picture

Status: Needs review » Needs work

Looks good, except that build is failing due to Unused use statement use Psr\Log\LoggerInterface;

rishi.kulshreshtha’s picture

Status: Needs work » Needs review

🤦 , now back to review.

capysara’s picture

Issue summary: View changes
StatusFileSize
new10.38 KB

I tested this manually with:
Drupal 10.0.0-dev
PHP 8.1.3
Using local environment ddev v1.19.0

I tried a few different drush commands (uli, help, coder, cim) and I can confirm that applying the patch in MR172 in comment #6 allows drush commands without throwing errors.

Drush commands are success after applying patch

narendrar’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Project Browser MVP

bnjmnm made their first commit to this issue’s fork.

bnjmnm’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for catching @ fixing this @Rishi Kulshreshtha, merged!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.