Currently, whenever we run composer update or composer dump-autoload, we get at least four meaningful pieces of diff caused by the recalculation of the AutoloaderInit suffix.
E.g. in #2175447-1: Update composer to latest version:

-return ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721::getLoader();
+return ComposerAutoloaderInitf089bd3ae5f9f883a3ebe89eb643eced::getLoader();
[..]
-class ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721
+class ComposerAutoloaderInitf089bd3ae5f9f883a3ebe89eb643eced
[..]
-        spl_autoload_register(array('ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721', 'loadClassLoader'), true, true);
+        spl_autoload_register(array('ComposerAutoloaderInitf089bd3ae5f9f883a3ebe89eb643eced', 'loadClassLoader'), true, true);
[..]
-        spl_autoload_unregister(array('ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721', 'loadClassLoader'));
+        spl_autoload_unregister(array('ComposerAutoloaderInitf089bd3ae5f9f883a3ebe89eb643eced', 'loadClassLoader'));

There is a way to avoid this noise:
http://getcomposer.org/doc/04-schema.md
Look for "autoloader-suffix".
We could set this to e.g. "Drupal8" and be done with it.

The purpose of the random-generated suffix is to avoid collisions with other instances of Composer used in the same process/request.
I think we can expect that only one of these instances will be from a Drupal 8 installation. And even if there were more than one instance from Drupal 8, our current solution won't help at all because each of those instances will have the same random-generated suffix.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donquixote’s picture

Status: Active » Needs review
FileSize
1.74 KB

Status: Needs review » Needs work

The last submitted patch, 1: D8-composer-autoloader-suffix-2176265-1.patch, failed testing.

donquixote’s picture

Status: Needs work » Needs review
larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Awesome

tim.plunkett’s picture

Yeah, that suffix really worried me when I was working on the other patch, this is great.

dawehner’s picture

Nice!

webchick’s picture

Status: Reviewed & tested by the community » Needs work

This patch is awesome.

However, it no longer applies. :(

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
1.74 KB
donquixote’s picture

Status: Needs review » Reviewed & tested by the community

Patch from #8 still applies, Drupal install works fine for me, and "composer install" gives me an empty changeset.
Seems all fine for rtbc!

donquixote’s picture

I correct myself: "composer install" is meaningless.
But "composer update" has the same effect with or without, except for the magic random suffix and composer.lock.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome-sauce! This patch makes me very happyyyyy! :D :D

Committed and pushed to 8.x. Thanks!

I did have one question though, which is whether or not the "8" suffix there makes sense. It means we need to remember to change this again in Drupal 9. Is this nomenclature common in other composer-ish projects, or is "Drupal" sufficient? If so, could we get a quick follow-up for that?

donquixote’s picture

The goal of this suffix is to avoid name clashes if more than one composer instance is at work. The more unique this name is, the better. The simple logic here is that "Drupal8" is more unique than just "Drupal". Anything beyond that would not be possible, because all we know at this point, for a hardcoded suffix, is that we are in Drupal 8.

By default, this composer.json setting would be empty, and Composer will generate a random string instead. But these projects don't put the vendor stuff in a git repo. Not even in your local application/site repo.
You are supposed to run composer install or composer update after every git checkout.

But Drupal is special, because it has all the vendor/ stuff in the main repository.

I imagine or hope that in Drupal 9, and the vendor/ stuff will no longer be in the same repo with Drupal core.

If this is not the case, we will have AutoloaderInitDrupal9, which means it will be possible (theoretically) to have some stuff from a Drupal8 instance, and some other stuff from a Drupal9 instance, in the same request. Probably going to break anyway, but then at least we can't blame the AutoloaderInit suffix.

If we had a more unique suffix, e.g. AutoloaderInitMySiteDrupal8 vs AutoloaderInitOtherSiteDrupal8, then we could even have stuff from two Drupal8 instances in the same request. But this is not possible, because we can only have one suffix in the repository.

Hope this makes sense :)

Of course we could still say "nah", this is ugly, we don't like it, let's name it to just "Drupal". It won't be a big loss.

Status: Fixed » Closed (fixed)

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