-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Refactor Drush's own bootstrap into drush_preflight() and move rest to new DrupalBoot class #624
Conversation
…ass owns the rest of the bootstrap.
register_shutdown_function('drush_shutdown'); | ||
|
||
// Not used? | ||
// drush_set_context('DRUSH_BOOTSTRAP_PHASE', DRUSH_BOOTSTRAP_NONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRUSH_BOOTSTRAP_PHASE is used a couple of places to see if a Drupal site has been selected, etc.; might be better to provide an API for this, and discourage or prohibit folks from looking at the bootstrap phase directly.
Direction looks great. I haven't tried it, but I'm in favor of committing and pushing forward from here once tests are cleaned up. |
@grugnog - when trying to fix --early handling, you can just add commits to the |
…) breaking tests.
The issue was that separate calls to the alias and command-name caches were causing a cache miss (which triggered a full rebuild) followed by a later cache hit. We validate cache misses though asserting that no hit's are present, and hence this was breaking the tests. To resolve this, I simply added a static cache to the function, so it no longer attempts to load a cache after it has already rebuilt the main completion array. In other words, I think the tests should have been failing here, and this patch just uncovered the actual issue. The follow-up question then would be - why are the tests passing on master when they shouldn't be? Looking at the output it seems like something may have regressed with caching on master (but fixed here), but it needs further investigation. |
Thanks @grugnog. @greg-1-anderson - Any chance you can fix the merge conflict that this PR now has? The way to do that is to run |
… Active dir. Maybe we should stop emptying staging but thats a separate issue.
…at() and query_prefix on an . This is the now the duty of the caller in this case. We'll need to fix regressions as they come up.
…ass owns the rest of the bootstrap.
…) breaking tests.
I think that should do it -- but I'm not staying up to see if the Travis build passes. :) (For some reason, while I can run individual tests locally, I get false failures when I try to run all tests at once. Haven't spent the time to try to figure out why that is yet.) |
Not quite right. |
…etting uri via cwd still does not happen until the 'bootstrap root' phase, after the kind of site (still only Drupal supported) is known.
I pushed another commit that insures that root and uri are set earlier in the bootstrap. This still isn't quite enough to fix everything, as commands such as 'status' and 'site-alias' (anything that only goes through the 'preflight' / formerly known as drush_bootstrap_drush) will dispatch before the code that sets uri from cwd is executed. This is pretty close to right, as drush_bootstrap_max will still do the right thing, but it means that Some more refactoring of bootstrap responsibilities could be done. Also, I moved _drush_bootstrap_select_drupal_site() to preflight, so this method could perhaps be renamed. I'm okay with either continuing to work with this on the branch, or just committing to master & continuing the cleanup there. We'd just need to touch up the tests to "fix" the known failures. |
I configured .travis.yml so that it starts testing this branch. I'll help fix the fails. Thanks for the effort here, folks. |
Since we are processing --uri and --root during preflight, I'd be OK with doing the cwd discovery of uri as well during preflight. |
The thing about uri discovery is that it requires Drupal-specific code. If we want to leave ourselves open to (a) uri discovery that runs Drupal code, (b) uri discovery that is different in D7 & D8, or (c) support for other CMS systems such as Backdrop, Wordpress, etc., then we should: i. Load all of the bootstrap classes in preflight Then bootstrap as we currently do. I think this would be worth doing. The main prereq would be to move all of the lib/Drupal/Boot/bootstrap.inc code into a class, and invent some easy heuristic for Drush to find bootstrap classes. Maybe we could do this after we load the initial Drush commandfiles late in the preflight, and call a commandfile hook to get bootstrap class names (or just have it instantiate and return a bootstrap class). |
This PR implements #342 |
…ault in drush_get_context().
…tstrap_validate().
…ocess() to isolate steps better.
… be on the class but lets just keep the copy in Drush/Boot/bootstrap.inc
We are now green, with barely any changes needed. I'll merge this in the morning - too tired now. In 5d63fcd I removed the call to _drush_bootstrap_select_drupal_site() during every bootstrap phase. That's now done only during the SITE bootstrap phase as I didn't see a use case for arbitrary changes to URI and we were actually resetting uri to NULL in one test fail that I debugged. |
Refactor Drush's own bootstrap into drush_preflight() and move the rest of bootstrap into a new DrupalBoot class.
I've merged this PR. Let's keep cleaning preflight and DrupalBoot until they look pretty. |
Drupal 8 is about to significantly change its bootstrap (removes early phases), so I decided to refactor Drush in preparation. I will say that we can likely handle D8 within the current Drush bootstrap model so we shouldn't feel obligated to commit this PR. Feedback welcome.
Conceptually, this PR improves the separation of Drush from Drupal. Specifically, a new Drupal "Boot" class now owns the bootstrap process, as I've moved Drush's own bootstrap to a new preflight stage. This separation lets us think more clearly about two potential directions for Drush (not mutually exclusive):
Code changes
Known issues