Set all package ids only once the pool is created

They all get set in one place only and at a specific time when nothing
else will possibly change them anymore
main
Nils Adermann 6 years ago
parent 5c491ecc9b
commit 81bb8f81ad

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

@ -32,7 +32,6 @@ class PoolBuilder
private $loadedNames = array();
private $id = 1;
private $packages = 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)) {
$loadIds = array();
foreach ($repositories as $key => $repository) {
@ -117,9 +108,8 @@ class PoolBuilder
private function loadPackage(PackageInterface $package, $repoIndex)
{
$package->setId($this->id++);
$this->packages[] = $package;
$this->priorities[$this->id - 2] = -$repoIndex;
$this->priorities[] = -$repoIndex;
// handle root package aliases
$name = $package->getName();
@ -130,7 +120,6 @@ class PoolBuilder
}
$aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
$aliasPackage->setRootPackageAlias(true);
$aliasPackage->setId($this->id++);
$package->getRepository()->addPackage($aliasPackage); // TODO do we need this?
$this->packages[] = $aliasPackage;

@ -297,16 +297,6 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
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 bool $bypassFilters If set to true, this bypasses the stability filtering, and forces a recompute without cache

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

@ -98,8 +98,6 @@ class RuleTest extends TestCase
$p1 = $this->getPackage('foo', '2.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);

Loading…
Cancel
Save