Drush fails on Drupal 10

Created on 16 October 2023, 8 months ago

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.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada hussainweb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @hussainweb
  • Status changed to Fixed 8 months ago
  • πŸ‡¨πŸ‡¦Canada hussainweb

    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`.

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

Production build 0.69.0 2024