Problem/Motivation

Running most drush commands results in this error:

In SiteProcess.php line 214:
                                                                               
  The command "/__w/backend/backend/vendor/bin/drush updatedb --no-cache-clea  
  r --yes --uri=default --root=/__w/backend/backend/web" failed.               
                                                                               
  Exit Code: 1(General error)                                                  
                                                                               
  Working directory:                                                           
                                                                               
  Output:                                                                      
  ================                                                             
                                                                               
  Fatal error: Type of Drupal\do_username\Commands\DOCopyFieldValues::$logger  
   must be ?Psr\Log\LoggerInterface (as in class Drush\Commands\DrushCommands  
  ) in /__w/backend/backend/web/modules/contrib/do_username/src/Commands/DOCo  
  pyFieldValues.php on line 15                                                 
                                                                               
                                                                               
  Error Output:                                                                
  ================                                                             
Warning:    [warning] Drush command terminated abnormally.

This happens for both Drush 11 and 12.

Steps to reproduce

Run a command such as `drush deploy`.

Proposed resolution

Fix the argument type error.

Comments

hussainweb created an issue. See original summary.

  • hussainweb committed 0cda6c4b on 2.x
    Issue #3394443 by hussainweb: Drush fails on Drupal 10
    
hussainweb’s picture

Status: Active » Fixed

Just removing the $logger property on the class is sufficient. That property is made available by LoggerAwareTrait anyway and the error was due to different types (it needed to be `?LoggerInterface` whereas it was missing and assumed `mixed` in the module's class).

We can still set to the property in the constructor because LoggerInterface is compatible with Drupal's `\Drupal\Core\Logger\LoggerChannelInterface`.

Status: Fixed » Closed (fixed)

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