I have a server with multiple Drupal 6 installs on it. On one of them, I can run drush status just fine. All the rest, I get an unrecoverable error. All sites run fine in a browser.

Is there any documentation on how I can troubleshoot this?

Here's the debug:

$ drush -d status
Bootstrap to phase 0. [0.02 sec, 2.47 MB]                            [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.03 sec, 2.67 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.06 sec, 5.49 MB]                                            [bootstrap]
Initialized Drupal 6.14 root directory at /var/www/example.com/public_html [0.07 sec, 6.27 MB]                           [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.08 sec, 6.28 MB]                                            [bootstrap]
Initialized Drupal site default at sites/default [0.08 sec, 6.28 MB]                                                     [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.08 sec, 6.28 MB]                                   [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.09 sec, 6.32 MB]                                        [bootstrap]
Successfully connected to the Drupal database. [0.09 sec, 6.32 MB]                                                    [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.09 sec, 6.63 MB]                                            [bootstrap]
Drush command terminated abnormally due to an unrecoverable error. [0.31 sec, 27.72 MB] 

Comments

mmilano’s picture

Update: I get the same behavior on 4.x dev and 5.x dev. I've removed all drushrc.php files from the mix in case there was a bad custom config somewhere, but the results are the same.

greg.1.anderson’s picture

Is there some module or set of modules that are installed on the sites that don't work that is not installed on the site that does work?

mmilano’s picture

It's pretty confusing now.

Server A: Has 4 sites, 1 works with drush, all others get the error when running anything. This one is running PHP 5.3, confirmed same version in the CLI.

Server B: I copied one of the sites that don't work on Server A over, including the DB, and I am able to run drush on that site. This one is running PHP 5.2

Both servers have pdo and mysql pdo installed.

greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

You could disable modules on the non-working sites on server A until drush started working. Skip the modules that are enabled on the working site on server A. Use a copy of the sites, of course.

Some modules might not work on php 5.3. I recently had to update date and calendar modules on an old site I inherited before it would run on 5.3. Of course, in that instance they didn't work in the browser either, but the same concept may apply.

mmilano’s picture

Well, I found the offender, but I'm still confused as to why it works on one environment and not the other.

The content of the site is wine based, and we have a cookie check in hook_init(). If they don't have the cookie, it redirects them to the age form that asks them their age and sets the cookie.

The exact line that is causing the problem is the drupal_goto(), which would definitely be getting hit.

Why would drupal_goto() in hook_init() kill drush on PHP 5.3 and not 5.2? The destination of drupal_goto() does not trigger another drupal_goto(). This module is setup with a heavier weight than anything else to make sure it doesn't short out the others.

Is there anything in the bootstrap that I can detect if drush is running, so I can set my age check to let drush through? Adding code to accommodate drush is a last resort, but not out of the question.

brunorios1’s picture

i'm having the same problem described in #5...

i have a custom module with drupal_goto() in hook_init() and i'm getting a "Drush command terminated abnormally due to an unrecoverable error."

greg.1.anderson’s picture

Title: Drush status: unrecoverable error » drupal_goto() kills drush if called in hook_init()
Status: Postponed (maintainer needs more info) » Fixed

This is the same issue as #827478: Disable a module ONLY for drush's bootstrap?; unfortunately, the only way to solve the problem is to wrap your call to drupal_goto in your hook init with a check for drush.

  if (!function_exists('drush_main')) {
    drupal_goto(...);
  }
brunorios1’s picture

thanks greg!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sobi3ch’s picture

With Jenkins job running this
drush @TCS-OpenAtrium_stage -y vset site_offline 1
.. I get same problem again
Drush command terminated abnormally due to an unrecoverable error. [error]
So I found simple solution to check that accually I'm in the CLI mode:

if (php_sapi_name() != 'cli') {
 // .. do stuff that not affect drush
}

http://stackoverflow.com/a/933375/473390