1
0
Fork 0

Merge pull request #1109 from Seldaek/newlock

Use only the locked repository when possible for better performance
pull/1110/merge
Nils Adermann 2012-09-14 08:51:04 -07:00
commit 3fa9f10184
3 changed files with 77 additions and 8 deletions

View File

@ -255,11 +255,14 @@ class Installer
$pool = new Pool($minimumStability, $stabilityFlags);
$pool->addRepository($installedRepo, $aliases);
if ($installFromLock) {
$pool->addRepository($lockedRepository);
$pool->addRepository($lockedRepository, $aliases);
}
$repositories = $this->repositoryManager->getRepositories();
foreach ($repositories as $repository) {
$pool->addRepository($repository, $aliases);
if (!$installFromLock || !$this->locker->isCompleteFormat($devMode)) {
$repositories = $this->repositoryManager->getRepositories();
foreach ($repositories as $repository) {
$pool->addRepository($repository, $aliases);
}
}
// creating requirements request

View File

@ -87,6 +87,24 @@ class Locker
return $this->hash === $lock['hash'];
}
/**
* Checks whether the lock file is in the new complete format or not
*
* @param bool $dev true to check in dev mode
* @return bool
*/
public function isCompleteFormat($dev)
{
$lockData = $this->getLockData();
$lockedPackages = $dev ? $lockData['packages-dev'] : $lockData['packages'];
if (empty($lockedPackages) || isset($lockedPackages[0]['name'])) {
return true;
}
return false;
}
/**
* 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;

View File

@ -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)