diff --git a/drush.php b/drush.php index 00c4e7f6c1..f80c116478 100755 --- a/drush.php +++ b/drush.php @@ -45,9 +45,7 @@ function drush_main() { * - 'early' files can bootstrap when needed. * - bootstrap constants are available. */ - $bootstrap_class = drush_get_option('bootstrap_class', 'Drush\Boot\DrupalBoot'); - $bootstrap = new $bootstrap_class; - drush_set_context('DRUSH_BOOTSTRAP_OBJECT', $bootstrap); + $bootstrap = drush_preflight_create_bootstrap_object(); $bootstrap->preflight(); $return = ''; @@ -70,7 +68,6 @@ function drush_main() { // perhaps handling immediately. $command_handled = drush_preflight_command_dispatch(); if (!$command_handled) { - $bootstrap = drush_get_context('DRUSH_BOOTSTRAP_OBJECT'); $return = $bootstrap->bootstrap_and_dispatch(); } } diff --git a/includes/preflight.inc b/includes/preflight.inc index 025989f280..7b5039b7a1 100644 --- a/includes/preflight.inc +++ b/includes/preflight.inc @@ -233,6 +233,13 @@ function drush_preflight() { _drush_find_commandfiles_drush(); } +function drush_preflight_create_bootstrap_object() { + $bootstrap_class = drush_get_option('bootstrap_class', 'Drush\Boot\DrupalBoot'); + $bootstrap = new $bootstrap_class; + drush_set_context('DRUSH_BOOTSTRAP_OBJECT', $bootstrap); + return $bootstrap; +} + function _drush_preflight_global_options() { // Debug implies verbose drush_set_context('DRUSH_VERBOSE', drush_get_option(array('verbose', 'debug'), FALSE));