1
0
Fork 0

Merge pull request #7629 from naderman/pool-ids

Generate Package Ids in pool only once all packages are defined
pull/7631/head
Nils Adermann 2018-09-12 14:54:54 +02:00 committed by GitHub
commit 468f24b230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 25 deletions

View File

@ -68,7 +68,10 @@ class Pool implements \Countable
$this->priorities = $priorities; $this->priorities = $priorities;
$this->packages = $packages; $this->packages = $packages;
$id = 1;
foreach ($this->packages as $package) { foreach ($this->packages as $package) {
$package->id = $id++;
$names = $package->getNames(); $names = $package->getNames();
$this->packageByExactName[$package->getName()][$package->id] = $package; $this->packageByExactName[$package->getName()][$package->id] = $package;

View File

@ -32,7 +32,6 @@ class PoolBuilder
private $loadedNames = array(); private $loadedNames = array();
private $id = 1;
private $packages = array(); private $packages = array();
private $priorities = array(); private $priorities = array();
@ -57,14 +56,6 @@ class PoolBuilder
} }
} }
foreach ($repositories as $repository) {
if ($repository instanceof ComposerRepository && $repository->hasProviders()) {
$this->providerRepos[] = $repository;
$repository->setRootAliases($this->rootAliases);
$repository->resetPackageIds();
}
}
while (!empty($loadNames)) { while (!empty($loadNames)) {
$loadIds = array(); $loadIds = array();
foreach ($repositories as $key => $repository) { foreach ($repositories as $key => $repository) {
@ -117,9 +108,8 @@ class PoolBuilder
private function loadPackage(PackageInterface $package, $repoIndex) private function loadPackage(PackageInterface $package, $repoIndex)
{ {
$package->setId($this->id++);
$this->packages[] = $package; $this->packages[] = $package;
$this->priorities[$this->id - 2] = -$repoIndex; $this->priorities[] = -$repoIndex;
// handle root package aliases // handle root package aliases
$name = $package->getName(); $name = $package->getName();
@ -130,7 +120,6 @@ class PoolBuilder
} }
$aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']); $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
$aliasPackage->setRootPackageAlias(true); $aliasPackage->setRootPackageAlias(true);
$aliasPackage->setId($this->id++);
$package->getRepository()->addPackage($aliasPackage); // TODO do we need this? $package->getRepository()->addPackage($aliasPackage); // TODO do we need this?
$this->packages[] = $aliasPackage; $this->packages[] = $aliasPackage;

View File

@ -297,16 +297,6 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $this->hasProviders; return $this->hasProviders;
} }
public function resetPackageIds()
{
foreach ($this->providersByUid as $package) {
if ($package instanceof AliasPackage) {
$package->getAliasOf()->setId(-1);
}
$package->setId(-1);
}
}
/** /**
* @param string $name package name * @param string $name package name
* @param bool $bypassFilters If set to true, this bypasses the stability filtering, and forces a recompute without cache * @param bool $bypassFilters If set to true, this bypasses the stability filtering, and forces a recompute without cache

View File

@ -143,7 +143,6 @@ class RuleSetTest extends TestCase
$pool->setPackages(array( $pool->setPackages(array(
$p = $this->getPackage('foo', '2.1'), $p = $this->getPackage('foo', '2.1'),
)); ));
$p->setId(1);
$ruleSet = new RuleSet; $ruleSet = new RuleSet;
$literal = $p->getId(); $literal = $p->getId();

View File

@ -98,8 +98,6 @@ class RuleTest extends TestCase
$p1 = $this->getPackage('foo', '2.1'), $p1 = $this->getPackage('foo', '2.1'),
$p2 = $this->getPackage('baz', '1.1'), $p2 = $this->getPackage('baz', '1.1'),
)); ));
$p1->setId(1);
$p2->setId(2);
$rule = new GenericRule(array($p1->getId(), -$p2->getId()), Rule::RULE_JOB_INSTALL, null); $rule = new GenericRule(array($p1->getId(), -$p2->getId()), Rule::RULE_JOB_INSTALL, null);