hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
939 stars 560 forks source link

[ *console* ] drupal cr triggers a fatal uncaught error #4261

Open bkline opened 3 years ago

bkline commented 3 years ago

Problem/Motivation

The issue was filed because clearing the Drupal cache is an essential part of a Drupal developer's workday.

How to reproduce

Here are the steps which led to the failure.

  1. install fresh Drupal 9.3
  2. install Drupal Console 1.9.5
  3. create and enable a custom module
  4. run ../vendor/bin/drupal deco ...
  5. run ../vendor/bin/drupal cr
  6. see stack trace
 Rebuilding cache(s), wait a moment please.
PHP Fatal error:  Uncaught Error: Call to undefined method Drupal\Core\DrupalKernel::prepareLegacyRequest() in /var/www/ebms/vendor/drupal/console/src/Utils/DrupalApi.php:266
Stack trace:
#0 /var/www/ebms/vendor/drupal/console/src/Command/Cache/RebuildCommand.php(104): Drupal\Console\Utils\DrupalApi->drupal_rebuild()
#1 /var/www/ebms/vendor/symfony/console/Command/Command.php(255): Drupal\Console\Command\Cache\RebuildCommand->execute()
#2 /var/www/ebms/vendor/symfony/console/Application.php(1018): Symfony\Component\Console\Command\Command->run()
#3 /var/www/ebms/vendor/symfony/console/Application.php(271): Symfony\Component\Console\Application->doRunCommand()
#4 /var/www/ebms/vendor/drupal/console-core/src/Application.php(187): Symfony\Component\Console\Application->doRun()
#5 /var/www/ebms/vendor/drupal/console/src/Application.php(64): Drupal\Console\Core\Application->doRun()
#6 /var/www/ebms/vendor/symfony/console/Application.php(147): Drupal\Console\Application->doRun()
#7 /var/www/ebms/vendor/drupal/console/bin/drupal.php( in /var/www/ebms/vendor/drupal/console/src/Utils/DrupalApi.php on line 266

Fatal error: Uncaught Error: Call to undefined method Drupal\Core\DrupalKernel::prepareLegacyRequest() in /var/www/ebms/vendor/drupal/console/src/Utils/DrupalApi.php on line 266

Error: Call to undefined method Drupal\Core\DrupalKernel::prepareLegacyRequest() in /var/www/ebms/vendor/drupal/console/src/Utils/DrupalApi.php on line 266

Call Stack:
    0.0006     388240   1. {main}() /var/www/ebms/vendor/drupal/console/bin/drupal:0
    0.0020     401312   2. require('/var/www/ebms/vendor/drupal/console/bin/drupal.php') /var/www/ebms/vendor/drupal/console/bin/drupal:4
    9.1764   22630160   3. Drupal\Console\Application->run() /var/www/ebms/vendor/drupal/console/bin/drupal.php:89
    9.1775   22636480   4. Drupal\Console\Application->doRun() /var/www/ebms/vendor/symfony/console/Application.php:147
   14.5769   31447080   5. Drupal\Console\Application->doRun() /var/www/ebms/vendor/drupal/console/src/Application.php:64
   15.1642   39527336   6. Drupal\Console\Application->doRun() /var/www/ebms/vendor/drupal/console-core/src/Application.php:187
   15.1645   39528408   7. Drupal\Console\Application->doRunCommand() /var/www/ebms/vendor/symfony/console/Application.php:271

Solution

Rewrite calls to undefined methods.

chriswales95 commented 3 years ago

Can second this. Just came across this myself when running a fresh install of Drupal 9 and installing Drupal Console.

ben74 commented 3 years ago

Same here .. fresh d9 install + drupal console .. hit on this error while rebuilding caches

flashvnn commented 3 years ago

Same here, i temporary remove code at line vendor/drupal/console/src/Utils/DrupalApi.php:266

$kernel->prepareLegacyRequest($request);

Drupal console work for now but need official update.

dhallek commented 3 years ago

Same problem here. The workaround of @flashvnn seems to fix it.

devagit commented 3 years ago

Same here: Drupal Console 1.9.5, Drupal Core 9.0.7

santiagoyie commented 3 years ago

I had the same error, but running drupal site:mode dev with Drupal Console version 1.9.7 and Drupal core 9.0.3. The workaround of @flashvnn seems to fix it for me too.

zietbukuel commented 3 years ago

I'm also having the same issue with Drupal 9.1.0 and Drupal Console 1.9.7.

jvanbiervliet commented 3 years ago

Same Drupal 9.1.0 Drupal Console 1.9.7 What's up with this ?

DigitalSolace commented 3 years ago

Same with Drupal Core 9.1.2 , Drupal Console 1.79.7.

DerH4NNES commented 3 years ago

Same with Drupal Core 9.1.3, 1.9.7

devkinetic commented 3 years ago

DrupalKernelInterface::prepareLegacyRequest.

Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use DrupalKernel::boot() and DrupalKernel::preHandle() instead.

acnimda commented 3 years ago

Same here, i temporary remove code at line vendor/drupal/console/src/Utils/DrupalApi.php:266

$kernel->prepareLegacyRequest($request);

Drupal console work for now but need official update.

@flashvnn This did work for me on latest drupal 9 version.

NOTE: drupal cr works but installing a module like so drupal moi doesn't work. It's a solution but not the best out there!

petiar commented 3 years ago

It looks like there's more deprecated functions in the Drupal console codebase.

For fixing the drupal cr command you need to replace the line 266 (the one with the prepareLegacyRequest() call with following lines:

$kernel->boot();
$kernel->preHandle($request);

There is also a PR for this, it's #4269

To fix the drupal moi command replace the line 178 (the one with the system_rebuild_module_data() call) in the src/Command/Shared/ProjectDownloadTrait.php with following:

$moduleList = \Drupal::service("extension.list.module")->getList();
acnimda commented 3 years ago

It looks like there's more deprecated functions in the Drupal console codebase.

For fixing the drupal cr command you need to replace the line 266 (the one with the prepareLegacyRequest() call with following lines:

$kernel->boot();
$kernel->preHandle($request);

There is also a PR for this, it's #4269

To fix the drupal moi command replace the line 178 (the one with the system_rebuild_module_data() call) in the src/Command/Shared/ProjectDownloadTrait.php with following:

$moduleList = \Drupal::service("extension.list.module")->getList();

Alright this works, great work!

MurzNN commented 2 years ago

Thanks, PR #4269 fixes that error! But why it is not merged yet almost year already?

BramDriesen commented 2 years ago

Would be great to see this one getting fixed and closed...

bkline commented 2 years ago

@MurzNN

... why it is not merged yet almost year already?

Because the project has been abandoned?

RSickenberg commented 2 years ago

The PR has been approved but no news on this 😔

bkline commented 2 years ago

@jmolivas (creator of drupal-console) last responded in the #drupal-console Slack channel November 30 of last year, so I'd say it's a pretty good guess that this project is dead. ⚰️

BramDriesen commented 2 years ago

last responded in the #drupal-console Slack channel

Pretty strange to base yourself on the Drupal slack channel. To check if a repository is active or "dead".

The last commit on the repo here was on 15th of september (https://github.com/hechoendrupal/drupal-console/commit/b95700736df39b09c39e7a43d4cc2822147db621).

@jmolivas is not the only maintainer. So saying this project is "dead" is a bold statement to make...

I do believe this project could use a few extra active maintainers that could work on clearing the queue and bring this project back up to speed.

Those are the current maintainers, maybe try poking some of them as well.

https://github.com/orgs/hechoendrupal/people

RSickenberg commented 2 years ago

~The https://github.com/simonf7/drupal-console seems further from this repo.~

BramDriesen commented 2 years ago

The https://github.com/simonf7/drupal-console seems further from this repo.

No, those are commits for a merge request: https://github.com/hechoendrupal/drupal-console/pull/4321

RSickenberg commented 2 years ago

The https://github.com/simonf7/drupal-console seems further from this repo.

No, those are commits for a merge request: #4321

Oh, ok. My bad.

bkline commented 9 months ago

If this project isn't dead, it's showing all the signs of being in a coma. 😉