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

Reference: https://www.drupal.org/core/beta-changes
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()

Comments

tstoeckler’s picture

Status: Active » Needs review
StatusFileSize
new3.78 KB

Status: Needs review » Needs work

The last submitted patch, 1: 2386247-1-install-class-loader.patch, failed testing.

tstoeckler’s picture

Issue summary: View changes

Added a note about how to make drush site-install actually work to the issue summary.

tstoeckler’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB

Status: Needs review » Needs work

The last submitted patch, 4: 2386247-4-install-class-loader.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Needs review
StatusFileSize
new822 bytes
new4 KB

Ahh, 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.

Status: Needs review » Needs work

The last submitted patch, 6: 2386247-6-install-class-loader.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Needs review
StatusFileSize
new550 bytes
new4 KB

Status: Needs review » Needs work

The last submitted patch, 8: 2386247-8-install-class-loader.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Needs review
StatusFileSize
new546 bytes
new4 KB

Please someone punch me.

tstoeckler’s picture

Issue summary: View changes

Updated the issue summary now that the two pull requests have been merged (@moshe weitzman++!!).

dawehner’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Add 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.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This makes a ton of sense. One small nit.

+++ b/core/includes/install.core.inc
@@ -84,7 +88,15 @@
+  // @todo Remove this when Drush is updated in the Drupal testing
+  //   infrastructure.

Can we get this issue created and referenced in the @todo

tstoeckler’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new652 bytes
new4.03 KB

Here we go.

Going back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This 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!

  • alexpott committed e2ca303 on 8.0.x
    Issue #2386247 by tstoeckler: install.php should pass the class loader...

Status: Fixed » Closed (fixed)

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