In this issue (http://drupal.org/node/1559486) we are trying to improve integration with domain and drush. Domain tries to bootstrap the drupal database from settings.php, during drush's configuration bootstrap phase. This causes problems when drush is not attempting to get to a full database bootstrap (like during sql-connect). Is there any helper function or other command that would allow other modules to determine how far of a bootstrap drush is attempting to reach? Any other solutions?

I have 2 potential solutions, not sure if either of them are desirable:
1) during drush_bootstrap, set a variable that saves the highest level boostrap that is currently being attempted, so other modules can read this
2) provide a helper function that looks up the currently executing command and displays its required bootstrap level.

Comments

moshe weitzman’s picture

Status: Active » Fixed

2) is doable today. Just call drush_get_command() and look at 'bootstrap' element.

greg.1.anderson’s picture

I would recommend against checking the bootstrap level in the command element. You only get one shot at initializing settings.php; if you decide to skip something because a command is only declared to bootstrap to DRUSH_BOOTSTRAP_DRUPAL_SITE, and then later the command called drush_bootstrap_max, you may experience unexpected failures.

If you only want to skip your initialization during sql-connect, then I would explicitly special-case the sql-connect command, again using if (function_exists('drush_get_command')) { $command = drush_get_command(); } to find and key off of the command data.

If you are looking for a more general-purpose solution, then you could implement hook sql_connect_validate, and set a drush context or something in the command record there. This is not necessary if you are only interested in modifying your behavior during sql-connect, but it would allow you to extend your behavior change to other commands simply by implementing more validate hook functions. There is, however, a serious shortcomming to this technique, and that is that it will only work on commands that bootstrap to DRUSH_BOOTSTRAP_DRUSH, and then call drush_bootstrap_max() or drush_bootstrap_further (as the sql commands do); for other commands, your validate hook function would be called too later (after your settings.php was already included).

Status: Fixed » Closed (fixed)

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