Problem/Motivation
Drupal cannot be installed by an external script if that external script is bootstrapped via Composer's autoloader and that autoloader contains Drupal as well.
For a more concrete use-case, given a Composer project that pulls in both Drupal and Drush, drush site-install will not work. Drush will bootstrap itself with Composer's autoloader (the one in /path/to/project/vendor/autoload.php) and then the installer will include Drupal's autoloader (the one in /path/to/drupal/core/vendor/autoload.php). Both will try to require core/lib/Drupal.php and, thus, the second one fails.
Proposed resolution
The basic idea is to remove loading an autoloader from somewhere else than the frontcontrollers (index.php, install.php, ...).
Pass down the classloader into install_drupal() and install_being_request(). That way Drush and other scripts can pass in the right classloader from the start.
Note that for drush site-install to work, the latest Drush master is required and the following hunk must be applied to drush_core_site_install_version() in commands/core/drupal/site_install.inc:
$msg .= ' Consider using the --notify global option.';
}
drush_log(dt($msg), 'ok');
- drush_op('install_drupal', $settings);
+ $class_loader = drush_drupal_load_autoloader(DRUPAL_ROOT);
+ drush_op('install_drupal', $class_loader, $settings);
drush_log(dt('Installation complete. User name: @name User password: @pass', array('@name' => $account_name, '@pass' => $account_pass)), 'ok');
}
Remaining tasks
User interface changes
Note.
API changes
install_drupal() and install_begin_request() have a new (non-optional) $class_loader argument.
Beta phase evaluation
| Issue category | Bug because external scripts cannot install Drupal (if they share an autoloader with Drupal) |
|---|---|
| Issue priority | Not critical because the web installer is not affected |
| Unfrozen changes | Not unfrozen |
| Prioritized changes | This is not a prioritized change for the beta phase. |
| Disruption | Non-disruptive because the only API changes are to install_drupal() and install_begin_request() |
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 2386247-14-install-class-loader.patch | 4.03 KB | tstoeckler |
Comments
Comment #1
tstoecklerComment #3
tstoecklerAdded a note about how to make
drush site-installactually work to the issue summary.Comment #4
tstoecklerComment #6
tstoecklerAhh, this is one of those pesky places where we're hit by the testbot using Drush to install Drupal.
Added a BC layer for now.
Comment #8
tstoecklerComment #10
tstoecklerPlease someone punch me.
Comment #11
tstoecklerUpdated the issue summary now that the two pull requests have been merged (@moshe weitzman++!!).
Comment #12
dawehnerAdd an additional summary into the issue summary.
Given that I think this is not only about enabling a composer workflow but also make the dependencies of the installer more clear.
Comment #13
alexpottThis makes a ton of sense. One small nit.
Can we get this issue created and referenced in the @todo
Comment #14
tstoecklerHere we go.
Going back to RTBC.
Comment #15
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed e2ca303 and pushed to 8.0.x. Thanks!