1
0
Fork 0

Correctly load branch aliases from lock file

Root aliases are also stored in the lock file, so on install do not read
them from composer.json.
pull/7936/head
Nils Adermann 2019-11-07 20:40:28 +01:00
parent cc274ebdf4
commit c50d236378
4 changed files with 11 additions and 3 deletions

View File

@ -262,7 +262,7 @@ class RuleSetGenerator
foreach ($request->getFixedPackages() as $package) { foreach ($request->getFixedPackages() as $package) {
if ($package->id == -1) { if ($package->id == -1) {
throw new \RuntimeException("Fixed package ".$package->getName()." was not added to solver pool."); throw new \RuntimeException("Fixed package ".$package->getName()." ".$package->getVersion().($package instanceof AliasPackage ? " (alias)" : "")." was not added to solver pool.");
} }
$this->addRulesForPackage($package, $ignorePlatformReqs); $this->addRulesForPackage($package, $ignorePlatformReqs);

View File

@ -658,7 +658,8 @@ class Installer
// creating repository set // creating repository set
$policy = $this->createPolicy(false); $policy = $this->createPolicy(false);
$repositorySet = $this->createRepositorySet($platformRepo, $aliases, $lockedRepository); // use aliases from lock file only, so empty root aliases here
$repositorySet = $this->createRepositorySet($platformRepo, array(), $lockedRepository);
$repositorySet->addRepository($lockedRepository); $repositorySet->addRepository($lockedRepository);
$this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>'); $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
@ -708,6 +709,8 @@ class Installer
// TODO should we warn people / error if plugins in vendor folder do not match contents of lock file before update? // TODO should we warn people / error if plugins in vendor folder do not match contents of lock file before update?
//$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $repositorySet, $installedRepo, $request, $lockTransaction); //$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $repositorySet, $installedRepo, $request, $lockTransaction);
} else {
// need to still create the pool to reconstruct aliases
} }
// TODO in how far do we need to do anything here to ensure dev packages being updated to latest in lock without version change are treated correctly? // TODO in how far do we need to do anything here to ensure dev packages being updated to latest in lock without version change are treated correctly?

View File

@ -176,6 +176,11 @@ class Locker
$package = $this->loader->load($info); $package = $this->loader->load($info);
$packages->addPackage($package); $packages->addPackage($package);
$packageByName[$package->getName()] = $package; $packageByName[$package->getName()] = $package;
if ($package instanceof AliasPackage) {
$packages->addPackage($package->getAliasOf());
$packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
}
} }
if (isset($lockData['aliases'])) { if (isset($lockData['aliases'])) {

View File

@ -31,6 +31,6 @@ Installing double aliased package
install install
--EXPECT-- --EXPECT--
Installing b/b (dev-foo) Installing b/b (dev-foo)
Marking b/b (1.0.x-dev) as installed, alias of b/b (dev-foo)
Marking b/b (dev-master) as installed, alias of b/b (dev-foo) Marking b/b (dev-master) as installed, alias of b/b (dev-foo)
Marking b/b (1.0.x-dev) as installed, alias of b/b (dev-foo)
Installing a/a (dev-master) Installing a/a (dev-master)