Working on other issue I've found that DRUSH_DEBUG is set later than message logging starts. For example this is not shown without attached patch:

Bootstrap to phase 0. [0.04 sec, 1.13 MB]                            [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.05 sec, 1.27 MB] [bootstrap]
Loading drushrc "/etc/drush/drushrc.php"   [bootstrap]
into "system" scope. [0.05 sec, 1.28 MB]

Other separate issue I'm mixing here is that errors in the validation of a bootstrap phase are never shown from drush_main(). This is a very useful log information we are not getting when people submit issues, and also useful to prevent support issues. As an example, with mysql stopped (not the better example though):

without patch:

$drush cc
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through   [warning]
socket '/var/run/mysqld/mysqld.sock' (2)
Command cache-clear needs a higher bootstrap level to run - you will [error]
need invoke drush from a more functional Drupal environment to run
this command.
The drush command 'cc' could not be executed.                        [error]

with patch:

drush cc
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through   [warning]
socket '/var/run/mysqld/mysqld.sock' (2)
Command cache-clear needs a higher bootstrap level to run - you will [error]
need invoke drush from a more functional Drupal environment to run
this command.
The drush command 'cc' could not be executed.                        [error]
Drush was not able to start (bootstrap) the Drupal database.         [error]
Hint: This error often occurs when Drush is trying to bootstrap a
site that has not been installed or does not have a configured
database.

Drush was attempting to connect to : 
  Drupal version    : 6.20-dev
  Site URI          : http://d6
  Database driver   : mysqli
  Database hostname : localhost
  Database username : root
  Database name     : drupal_6
  Default theme     : garland
  Administration theme: garland
  PHP configuration : /etc/php5/cli/php.ini
  Drush version     : 4.0-dev
  Drush configuration:
/usr/src/drush-HEAD/examples/example.drushrc.php
  Drupal root       : /var/www/drupal-6.x-cvs
  Site path         : sites/d6
  Modules path      : sites/d6/modules
  Themes path       : sites/d6/themes
  %paths            : Array

You can select another site with a working database setup by
specifying the URI to use with the --uri parameter on the command
line or $options['uri'] in your drushrc.php file.

It seems that some change in the past put the access to that help information in the dark :/

Perhaps a cleaner approach can be made but just wanted to drop it here for feedback.

Comments

greg.1.anderson’s picture

Status: Active » Needs review
StatusFileSize
new3.06 KB

looks good to me, except you shouldn't have removed _drush_bootstrap_global_options(); from the end of _drush_bootstrap_drush(), as that function must be called any time global options might be defined or redefined, e.g. inside a drushrc.php file, which _drush_bootstrap_drush() loads.

Other than that, this patch tested out just fine.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

OK, lets commit then. Nice catch.

greg.1.anderson’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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