drush
drush copied to clipboard
CacheCommands autowiring appears broken.
Describe the bug Getting the following error on Drush 13.6; running Drupal 10.4.5.
Could not instantiate Drush\Commands\core\CacheCommands: Drush\Commands\core\CacheCommands::__construct(): Argument #4 ($jsOptimizer) must be of type Drupal\Core\Asset\JsCollectionOptimizerLazy, Drupal\Core\Asset\JsCollectionOptimizer given, called in /data/vendor/drush/drush/src/Commands/AutowireTrait.php on line 47
To Reproduce
drush list -vvv
Expected behavior
Expected the drush cache:* commands to exist and they didn't.
Actual behavior Autoload failed because the Autowiring returned one class (non-Lazy) and the function definition expected the Lazy version.
Workaround No, commands are currently missing.
System Configuration
| Q | A |
|---|---|
| Drush version? | 13.6.x |
| Drupal version? | 10.4.5 |
| PHP version | 8.3.x |
| OS? | Linux |
In my Drupal install, I am receiving a JsCollectionOptimizerLazy so no error. I dont know in what circumstances a non-lazy variant is received. We could remove the type hint but I'd rather understand this a bit better.
So JsCollectionOptimizerLazy is the right type...
https://git.drupalcode.org/project/drupal/-/blob/10.6.x/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php?ref_type=heads#L5
So I have to look at why mine is returning what it does.
Thanks for pointing out the issue.