Use only the locked repository when possible for better performance
parent
83239aa338
commit
418e876e8a
|
@ -255,12 +255,15 @@ class Installer
|
|||
$pool = new Pool($minimumStability, $stabilityFlags);
|
||||
$pool->addRepository($installedRepo, $aliases);
|
||||
if ($installFromLock) {
|
||||
$pool->addRepository($lockedRepository);
|
||||
$pool->addRepository($lockedRepository, $aliases);
|
||||
}
|
||||
|
||||
if (!$installFromLock || $this->locker->isLegacyFormat($devMode)) {
|
||||
$repositories = $this->repositoryManager->getRepositories();
|
||||
foreach ($repositories as $repository) {
|
||||
$pool->addRepository($repository, $aliases);
|
||||
}
|
||||
}
|
||||
|
||||
// creating requirements request
|
||||
$request = new Request($pool);
|
||||
|
|
|
@ -87,6 +87,24 @@ class Locker
|
|||
return $this->hash === $lock['hash'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the lock file is in the legacy format
|
||||
*
|
||||
* @param bool $dev true to check in dev mode
|
||||
* @return bool
|
||||
*/
|
||||
public function isLegacyFormat($dev)
|
||||
{
|
||||
$lockData = $this->getLockData();
|
||||
$lockedPackages = $dev ? $lockData['packages-dev'] : $lockData['packages'];
|
||||
|
||||
if (empty($lockedPackages) || isset($lockedPackages[0]['name'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches and returns an array of locked packages, retrieved from registered repositories.
|
||||
*
|
||||
|
@ -129,9 +147,8 @@ class Locker
|
|||
if (!$package && !empty($info['alias-version'])) {
|
||||
$package = $this->repositoryManager->findPackage($info['package'], $info['version']);
|
||||
if ($package) {
|
||||
$alias = new AliasPackage($package, $info['alias-version'], $info['alias-pretty-version']);
|
||||
$package->getRepository()->addPackage($alias);
|
||||
$package = $alias;
|
||||
$package->setAlias($info['alias-version']);
|
||||
$package->setPrettyAlias($info['alias-pretty-version']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +159,15 @@ class Locker
|
|||
));
|
||||
}
|
||||
|
||||
$packages->addPackage(clone $package);
|
||||
$package = clone $package;
|
||||
if (!empty($info['time'])) {
|
||||
$package->setReleaseDate($info['time']);
|
||||
}
|
||||
if (!empty($info['source-reference'])) {
|
||||
$package->setSourceReference($info['source-reference']);
|
||||
}
|
||||
|
||||
$packages->addPackage($package);
|
||||
}
|
||||
|
||||
return $packages;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
--TEST--
|
||||
Installing an old alias that doesn't exist anymore from a lock is possible
|
||||
--COMPOSER--
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": [
|
||||
{
|
||||
"name": "a/a", "version": "dev-master",
|
||||
"extra": { "branch-alias": { "dev-master": "2.2.x-dev" } },
|
||||
"source": { "reference": "master", "type": "git", "url": "" }
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"a/a": "2.1.*"
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
--LOCK--
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "a/a", "version": "dev-master", "version_normalized": "9999999-dev",
|
||||
"extra": { "branch-alias": { "dev-master": "2.1.x-dev" } },
|
||||
"source": { "reference": "oldmaster", "type": "git", "url": "" },
|
||||
"type": "library"
|
||||
}
|
||||
],
|
||||
"packages-dev": null,
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": []
|
||||
}
|
||||
--RUN--
|
||||
install
|
||||
--EXPECT--
|
||||
Installing a/a (dev-master oldmaster)
|
||||
Marking a/a (2.1.x-dev oldmaster) as installed, alias of a/a (dev-master oldmaster)
|
Loading…
Reference in New Issue