Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bkline opened this issue Aug 15, 2020 · 24 comments
Open

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

bkline opened this issue Aug 15, 2020 · 24 comments

Comments

@bkline
Copy link

bkline commented Aug 15, 2020

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 bkline changed the title [ *console* ] drupal cr triggers a fatal uncaught error [ *console* ] drupal cr triggers a fatal uncaught error Aug 15, 2020
@chriswales95
Copy link

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

@ben74
Copy link

ben74 commented Oct 10, 2020

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

@flashvnn
Copy link

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
Copy link

dhallek commented Nov 5, 2020

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

@devagit
Copy link

devagit commented Nov 14, 2020

Same here: Drupal Console 1.9.5, Drupal Core 9.0.7

@santiagoyie
Copy link

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
Copy link

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

@jvanbiervliet
Copy link

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

@DigitalSolace
Copy link

Same with Drupal Core 9.1.2 , Drupal Console 1.79.7.

@DerH4NNES
Copy link

Same with Drupal Core 9.1.3, 1.9.7

@devkinetic
Copy link

DrupalKernelInterface::prepareLegacyRequest.

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

@acnimda
Copy link

acnimda commented Mar 19, 2021

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!

@petiar
Copy link

petiar commented Mar 26, 2021

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
Copy link

acnimda commented Apr 19, 2021

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
Copy link

MurzNN commented Aug 20, 2021

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

@BramDriesen
Copy link

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

@bkline
Copy link
Author

bkline commented Oct 6, 2021

@MurzNN

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

Because the project has been abandoned?

@RSickenberg
Copy link

The PR has been approved but no news on this 😔

@bkline
Copy link
Author

bkline commented Oct 14, 2021

@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
Copy link

BramDriesen commented Oct 15, 2021

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 (b957007).

@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
Copy link

RSickenberg commented Oct 18, 2021

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

@BramDriesen
Copy link

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

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

@RSickenberg
Copy link

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
Copy link
Author

bkline commented Oct 19, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests