drupal-console icon indicating copy to clipboard operation
drupal-console copied to clipboard

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

Open bkline opened this issue 4 years ago • 24 comments

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.

bkline avatar Aug 15 '20 17:08 bkline

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

chriswales95 avatar Aug 30 '20 13:08 chriswales95

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

ben74 avatar Oct 10 '20 09:10 ben74

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 avatar Oct 17 '20 06:10 flashvnn

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

dhallek avatar Nov 05 '20 08:11 dhallek

Same here: Drupal Console 1.9.5, Drupal Core 9.0.7

devagit avatar Nov 14 '20 22:11 devagit

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.

santiagoyie avatar Dec 15 '20 17:12 santiagoyie

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

zietbukuel avatar Dec 19 '20 14:12 zietbukuel

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

jvanbiervliet avatar Dec 21 '20 13:12 jvanbiervliet

Same with Drupal Core 9.1.2 , Drupal Console 1.79.7.

DigitalSolace avatar Jan 18 '21 09:01 DigitalSolace

Same with Drupal Core 9.1.3, 1.9.7

DerH4NNES avatar Jan 27 '21 10:01 DerH4NNES

DrupalKernelInterface::prepareLegacyRequest.

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

devkinetic avatar Jan 27 '21 18:01 devkinetic

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.

  • go to vendor/drupal/console/src/Utils/DrupalApi.php uncomment somehwere around line 265: // Prepare a NULL request. // $kernel->prepareLegacyRequest($request);

prepareLegacyRequest(Request $request) didn't solve the issue.

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!

acnimda avatar Mar 19 '21 10:03 acnimda

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();

petiar avatar Mar 26 '21 18:03 petiar

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!

acnimda avatar Apr 19 '21 12:04 acnimda

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

MurzNN avatar Aug 20 '21 06:08 MurzNN

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

BramDriesen avatar Oct 06 '21 08:10 BramDriesen

@MurzNN

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

Because the project has been abandoned?

bkline avatar Oct 06 '21 10:10 bkline

The PR has been approved but no news on this 😔

RSickenberg avatar Oct 14 '21 13:10 RSickenberg

@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. ⚰️

bkline avatar Oct 14 '21 22:10 bkline

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

  • @dmouse
  • @LOBsTerr
  • @marcelovani
  • @moneda
  • @MontealegreLuis

BramDriesen avatar Oct 15 '21 13:10 BramDriesen

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

RSickenberg avatar Oct 18 '21 09:10 RSickenberg

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

BramDriesen avatar Oct 18 '21 09:10 BramDriesen

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.

RSickenberg avatar Oct 18 '21 11:10 RSickenberg

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

bkline avatar Oct 19 '23 10:10 bkline