1
0
Fork 0

Fixes #8065: Sort plugins deterministically before loading.

pull/8085/head
Dane Powell 2019-04-06 08:44:23 -07:00
parent 717c21b78a
commit 043b33ed38
No known key found for this signature in database
GPG Key ID: 5FCA7D7DAF2DDD5B
2 changed files with 10 additions and 4 deletions

View File

@ -28,6 +28,7 @@ use Composer\Script\ScriptEvents;
*/ */
class AutoloadGenerator class AutoloadGenerator
{ {
/** /**
* @var EventDispatcher * @var EventDispatcher
*/ */
@ -959,7 +960,7 @@ INITIALIZER;
* @param array $packageMap * @param array $packageMap
* @return array * @return array
*/ */
protected function sortPackageMap(array $packageMap) public function sortPackageMap(array $packageMap)
{ {
$packages = array(); $packages = array();
$paths = array(); $paths = array();

View File

@ -15,10 +15,10 @@ namespace Composer\Plugin;
use Composer\Composer; use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface; use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Package\CompletePackage;
use Composer\Package\Package; use Composer\Package\Package;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\Package\AliasPackage;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\Link; use Composer\Package\Link;
use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\Constraint;
@ -253,8 +253,13 @@ class PluginManager
*/ */
private function loadRepository(RepositoryInterface $repo) private function loadRepository(RepositoryInterface $repo)
{ {
foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */ $packages = $repo->getPackages();
if ($package instanceof AliasPackage) { $generator = $this->composer->getAutoloadGenerator();
$packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $this->composer->getPackage(), $packages);
$sortedPackageMap = array_reverse($generator->sortPackageMap($packageMap));
foreach ($sortedPackageMap as $fullPackage) {
$package = $fullPackage[0]; /** @var PackageInterface $package */
if (!($package instanceof CompletePackage)) {
continue; continue;
} }
if ('composer-plugin' === $package->getType()) { if ('composer-plugin' === $package->getType()) {