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

Drush fatal error with various commands -- looking for Drupal 8 RfcLogLevel #182

Open
jenlampton opened this issue Jul 9, 2019 · 16 comments

Comments

@jenlampton
Copy link
Member

jenlampton commented Jul 9, 2019

I'm seeing the following while attempting drush updb -y

Fatal error: Uncaught Error: Class 'Drupal\Core\Logger\RfcLogLevel' not found in drush-8/commands/core/drupal/environment.inc:334
@serundeputy
Copy link
Member

serundeputy commented Jul 11, 2019

@jenlampton do you have devel enabled with the show deprecated opiton checked as in #173 (comment) or is updb just always failing for you?

I have not had time to try to replicate myself yet.

I just tried on a vanilla Backdrop 1.x and drush updb -y ran successfully. Also worth noting that drush updb -y is passing tests in CI.

I just enabled devel w/ the deprecated option and drush updb -y still worked all be it with no updates available.

So we still need STR to get moving on this issue.

@bradbulger
Copy link

bradbulger commented Jul 15, 2019

When I get this error, it's running drush_watchdog_severity_levels() from the Drush phar code, not the version that is in .drush/commands/backdrop/. This is Drush 8.1.15.

update: ah, no, it's earlier. Drush 8 implements system_watchdog(), which gets called by any watchdog() error, and it is apparently not playing well with Backdrop.

@jenlampton jenlampton changed the title Drush updb now fatals looking for Drupal 8 RfcLogLevel Drush updb fatal - looking for Drupal 8 RfcLogLevel Jul 16, 2019
@jenlampton
Copy link
Member Author

jenlampton commented Jul 16, 2019

@serundeputy I found that I was still on the ongoing-saga-of-en branch for my checkout of Drush. When I switched to the 1.x-1.x branch updates work again :)

@bradbulger check your drush branch, are you on 1.x-1.x?

(going to close this issue -- @bradbulger please re-open if needed!)

@jackaponte
Copy link
Member

jackaponte commented Jul 19, 2019

Weirdly I'm seeing the same error under different circumstances, with just one site in just one environment:

drush cc all   
Error: Class 'Drupal\Core\Logger\RfcLogLevel' not found in drush_watchdog_severity_levels() (line 334 of /opt/drush/8/drush/drush/commands/core/drupal/environment.inc).
Drush command terminated abnormally due to an unrecoverable error. 

In the environment where this happens I'm running Backdrop 1.13.2, Drush 8.2.3, and the latest commit in branch 1.x-1.x of the Backdrop Drush commands; it occurs whether I use PHP 7.2 or PHP 7.3.

The identical site (same exact codebase) in a different environment using PHP 7.3 does not experience this error using the same versions of Drush and the Drush Backdrop commands. And other Backdrop sites in the same environment as the one with the problem do not experience the same error.

For the life of me I can't figure out what's going on here!

@jackaponte jackaponte reopened this Jul 19, 2019
@jackaponte jackaponte changed the title Drush updb fatal - looking for Drupal 8 RfcLogLevel Drush fatal error with various commands -- looking for Drupal 8 RfcLogLevel Jul 19, 2019
@jackaponte
Copy link
Member

Now I see I get the same error on a different site in the same environment. On this site drush cc all works fine but this doesn't:

drush dis devel
The following projects will be disabled: devel.
    Do you want to disable the projects? (y/n): y
Error: Class 'Drupal\Core\Logger\RfcLogLevel' not found in drush_watchdog_severity_levels() (line 334 of /opt/drush/8/drush/drush/commands/core/drupal/environment.inc).
Drush command terminated abnormally due to an unrecoverable error.  

But then look what happens when I immediately run this series of commands after that:

drush dis devel_generate
The following projects will be disabled: devel_generate.
    Do you want to disable the projects? (y/n): y

	Success: devel_generate are disabled.

drush dis devel
The following projects will be disabled: devel.
    Do you want to disable the projects? (y/n): y

	Success: devel are disabled.

drush en devel_generate
The following projects will be enabled: devel, devel_generate.
    Do you want to enable the projects? (y/n): y

	Success: module devel enabled.


	Success: module devel_generate enabled.

drush dis devel
The following projects will be disabled: devel_generate,devel.
    Do you want to disable the projects? (y/n): y

	Success: devel_generate,devel are disabled.

So...in some cases this problem comes and goes, but when it does happen, it's a fatal error?

@jenlampton
Copy link
Member Author

jenlampton commented Jul 20, 2019

@jackaponte check the drush branch, or if you have any patches applied. Maybe delete / replace drush where you are seeing the error, just to be sure?

@jackaponte
Copy link
Member

@jackaponte check the drush branch, or if you have any patches applied. Maybe delete / replace drush where you are seeing the error, just to be sure?

I'm using Drush 8.2.3 with no patches applied; I'm on the 1.x-1.x branch of the Backdrop commands, with commit ec2fa84d6 as the most recent commit and no difference from https://github.com/backdrop-contrib/drush.git according to git diff origin/1.x-1.x.

But as I noted before, the problem comes and goes, fairly inscrutably. When I started writing this update, drush cc all was working fine on one of the sites in my local environment, and now a few drush cc drushes later it's not working again. :(

@bradbulger
Copy link

I am not running drush from checked out code. I'm not entirely sure how to do that. This is my global Drush installation in /usr/local/bin/drush that's running a drush.phar file. The version is 8.1.15. (The "drush version" command does not work in a Backdrop context btw.)

It is loading system_watchdog() from phar:///usr/local/bin/drush.phar/includes/drupal.inc and that causes the attempt to run Drupal 8 code (or whatever the reference to RfcLogLevel is). If it only does this sometimes, then the question is, when does it include that file?

@jackaponte
Copy link
Member

@bradbulger Have you tried installing a fresh copy of the Drush Backdrop commands and seeing whether the issue persists for you? You can download the most recent 1.x-1.x release via this link: https://github.com/backdrop-contrib/drush/archive/1.x-1.x.zip

@jackaponte
Copy link
Member

Error: Class 'Drupal\Core\Logger\RfcLogLevel' not found persists for me on this one Backdrop 1.13.2 site, using Drush 8.2.3, Backdrop Drush 1.x-1.x and PHP 7.2.

Some observations in case they jog anyone's memory:

backdrop_pm_enable.drush.inc is the only Backdrop Drush file I can find that includes use Drupal\Core\Logger\RfcLogLevel; up at the very top; should that be there?

The error refers to line 334 of /opt/drush/8/drush/drush/commands/core/drupal/environment.inc. The code in reference:

/**
 * Helper function to obtain the severity levels based on Drupal version.
 *
 * @return array
 *   Watchdog severity levels keyed by RFC 3164 severities.
 */
function drush_watchdog_severity_levels() {
  return array(
    RfcLogLevel::EMERGENCY => LogLevel::EMERGENCY,
    RfcLogLevel::ALERT => LogLevel::ALERT,
...

That function is replaced in backdrop/includes/environment.inc. But maybe, on some sites, something is causing Drush to not properly detect that Backdrop is being used, causing the Drupal version of the function to be used instead?

@jackaponte
Copy link
Member

Welp, not long later I tried disabling then re-enabling civicrm and its dependent modules on the site where this was giving me trouble, and magically the error has gone away when running drush cc all (though I did get the error one last time when using drush to disable the modules.) I can't explain why. I'll update this if the error recurs anywhere!

@bugfolder
Copy link

FWIW, I just encountered this same error, and disabling civicrm made it go away. (Though re-enabling civicrm brought it back.)

@laryn
Copy link
Member

laryn commented Oct 1, 2020

Strange, I am using drush on a number of sites that run civicrm and am not seeing this. Which command in particular causes the error, @bugfolder?

@bugfolder
Copy link

It was drush dis, also drush pmu.

@klonos
Copy link
Member

klonos commented Apr 21, 2021

I confirm both drush dis and drush pmu having this issue:

drush dis node_clone -y
The following projects will be disabled: node_clone.
    Do you want to disable the projects? (y/n): y
Error: Class 'Drupal\Core\Logger\RfcLogLevel' not found in drush_watchdog_severity_levels() (line 294 of phar:///usr/local/bin/drush/commands/core/drupal/environment_common.inc).
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                   [error]
drush pmu node_clone -y
The following projects will be uninstalled: node_clone.
    Do you want to uninstall (could lose data) the projects? (y/n): y
Error: Class 'Drupal\Core\Logger\RfcLogLevel' not found in drush_watchdog_severity_levels() (line 294 of phar:///usr/local/bin/drush/commands/core/drupal/environment_common.inc).
Drush command terminated abnormally due to an unrecoverable error.

@herbdool
Copy link

herbdool commented Nov 22, 2021

I'm testing PHP 8 with backdrop-drush. I get this error in PHP 8 but not in PHP 7.4 (when running drush status). It happens all over the place because it's trying to actually log some other error and then encounters this fatal error.

Things have likely moved around a bit so the error is in environment_common.inc now:

PHP Fatal error: Uncaught Error: Class "Drupal\Core\Logger\RfcLogLevel" not found in phar:///usr/local/bin/drush/commands/core/drupal/environment_common.inc:294
Stack trace:
#0 phar:///usr/local/bin/drush/includes/drupal.inc(122): drush_watchdog_severity_levels()
#1 /app/core/includes/module.inc(975): system_watchdog(Array)
#2 /app/core/includes/bootstrap.inc(2329): module_invoke_all('watchdog', Array)
#3 /app/core/includes/errors.inc(214): watchdog('php', '%type: !message...', Array, 3)
#4 /app/core/includes/bootstrap.inc(2969): _backdrop_log_error(Array, true)

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

No branches or pull requests

8 participants