Make project id public
Reduction of rougly 1.3 million function calls on packagist updatepull/3481/head
parent
ef41f136f8
commit
c6af09b1da
|
@ -151,18 +151,18 @@ class DefaultPolicy implements PolicyInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// priority equal, sort by package id to make reproducible
|
// priority equal, sort by package id to make reproducible
|
||||||
if ($a->getId() === $b->getId()) {
|
if ($a->id === $b->id) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($a->getId() < $b->getId()) ? -1 : 1;
|
return ($a->id < $b->id) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($installedMap[$a->getId()])) {
|
if (isset($installedMap[$a->id])) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($installedMap[$b->getId()])) {
|
if (isset($installedMap[$b->id])) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class DefaultPolicy implements PolicyInterface
|
||||||
foreach ($literals as $literal) {
|
foreach ($literals as $literal) {
|
||||||
$package = $pool->literalToPackage($literal);
|
$package = $pool->literalToPackage($literal);
|
||||||
|
|
||||||
if (isset($installedMap[$package->getId()])) {
|
if (isset($installedMap[$package->id])) {
|
||||||
$selected[] = $literal;
|
$selected[] = $literal;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ class Pool
|
||||||
if ($exempt || $this->isPackageAcceptable($names, $stability)) {
|
if ($exempt || $this->isPackageAcceptable($names, $stability)) {
|
||||||
$package->setId($this->id++);
|
$package->setId($this->id++);
|
||||||
$this->packages[] = $package;
|
$this->packages[] = $package;
|
||||||
$this->packageByExactName[$package->getName()][$package->getId()] = $package;
|
$this->packageByExactName[$package->getName()][$package->id] = $package;
|
||||||
|
|
||||||
foreach ($names as $provided) {
|
foreach ($names as $provided) {
|
||||||
$this->packageByName[$provided][] = $package;
|
$this->packageByName[$provided][] = $package;
|
||||||
|
@ -122,7 +122,7 @@ class Pool
|
||||||
|
|
||||||
$package->getRepository()->addPackage($aliasPackage);
|
$package->getRepository()->addPackage($aliasPackage);
|
||||||
$this->packages[] = $aliasPackage;
|
$this->packages[] = $aliasPackage;
|
||||||
$this->packageByExactName[$aliasPackage->getName()][$aliasPackage->getId()] = $aliasPackage;
|
$this->packageByExactName[$aliasPackage->getName()][$aliasPackage->id] = $aliasPackage;
|
||||||
|
|
||||||
foreach ($aliasPackage->getNames() as $name) {
|
foreach ($aliasPackage->getNames() as $name) {
|
||||||
$this->packageByName[$name][] = $aliasPackage;
|
$this->packageByName[$name][] = $aliasPackage;
|
||||||
|
@ -186,7 +186,7 @@ class Pool
|
||||||
foreach ($this->providerRepos as $repo) {
|
foreach ($this->providerRepos as $repo) {
|
||||||
foreach ($repo->whatProvides($this, $name) as $candidate) {
|
foreach ($repo->whatProvides($this, $name) as $candidate) {
|
||||||
$candidates[] = $candidate;
|
$candidates[] = $candidate;
|
||||||
if ($candidate->getId() < 1) {
|
if ($candidate->id < 1) {
|
||||||
$candidate->setId($this->id++);
|
$candidate->setId($this->id++);
|
||||||
$this->packages[$this->id - 2] = $candidate;
|
$this->packages[$this->id - 2] = $candidate;
|
||||||
}
|
}
|
||||||
|
@ -217,8 +217,8 @@ class Pool
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->whitelist !== null && (
|
if ($this->whitelist !== null && (
|
||||||
(!($candidate instanceof AliasPackage) && !isset($this->whitelist[$candidate->getId()])) ||
|
(!($candidate instanceof AliasPackage) && !isset($this->whitelist[$candidate->id])) ||
|
||||||
($candidate instanceof AliasPackage && !isset($this->whitelist[$aliasOfCandidate->getId()]))
|
($candidate instanceof AliasPackage && !isset($this->whitelist[$aliasOfCandidate->id]))
|
||||||
)) {
|
)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ class Pool
|
||||||
{
|
{
|
||||||
$package = $this->literalToPackage($literal);
|
$package = $this->literalToPackage($literal);
|
||||||
|
|
||||||
if (isset($installedMap[$package->getId()])) {
|
if (isset($installedMap[$package->id])) {
|
||||||
$prefix = ($literal > 0 ? 'keep' : 'remove');
|
$prefix = ($literal > 0 ? 'keep' : 'remove');
|
||||||
} else {
|
} else {
|
||||||
$prefix = ($literal > 0 ? 'install' : 'don\'t install');
|
$prefix = ($literal > 0 ? 'install' : 'don\'t install');
|
||||||
|
|
|
@ -51,14 +51,14 @@ class RuleSetGenerator
|
||||||
*/
|
*/
|
||||||
protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
|
protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
|
||||||
{
|
{
|
||||||
$literals = array(-$package->getId());
|
$literals = array(-$package->id);
|
||||||
|
|
||||||
foreach ($providers as $provider) {
|
foreach ($providers as $provider) {
|
||||||
// self fulfilling rule?
|
// self fulfilling rule?
|
||||||
if ($provider === $package) {
|
if ($provider === $package) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$literals[] = $provider->getId();
|
$literals[] = $provider->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Rule($this->pool, $literals, $reason, $reasonData);
|
return new Rule($this->pool, $literals, $reason, $reasonData);
|
||||||
|
@ -80,7 +80,7 @@ class RuleSetGenerator
|
||||||
{
|
{
|
||||||
$literals = array();
|
$literals = array();
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
$literals[] = $package->getId();
|
$literals[] = $package->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Rule($this->pool, $literals, $reason, $job['packageName'], $job);
|
return new Rule($this->pool, $literals, $reason, $job['packageName'], $job);
|
||||||
|
@ -99,7 +99,7 @@ class RuleSetGenerator
|
||||||
*/
|
*/
|
||||||
protected function createRemoveRule(PackageInterface $package, $reason, $job)
|
protected function createRemoveRule(PackageInterface $package, $reason, $job)
|
||||||
{
|
{
|
||||||
return new Rule($this->pool, array(-$package->getId()), $reason, $job['packageName'], $job);
|
return new Rule($this->pool, array(-$package->id), $reason, $job['packageName'], $job);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +123,7 @@ class RuleSetGenerator
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Rule($this->pool, array(-$issuer->getId(), -$provider->getId()), $reason, $reasonData);
|
return new Rule($this->pool, array(-$issuer->id, -$provider->id), $reason, $reasonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,11 +151,11 @@ class RuleSetGenerator
|
||||||
|
|
||||||
while (!$workQueue->isEmpty()) {
|
while (!$workQueue->isEmpty()) {
|
||||||
$package = $workQueue->dequeue();
|
$package = $workQueue->dequeue();
|
||||||
if (isset($this->whitelistedMap[$package->getId()])) {
|
if (isset($this->whitelistedMap[$package->id])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->whitelistedMap[$package->getId()] = true;
|
$this->whitelistedMap[$package->id] = true;
|
||||||
|
|
||||||
foreach ($package->getRequires() as $link) {
|
foreach ($package->getRequires() as $link) {
|
||||||
$possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint(), true);
|
$possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint(), true);
|
||||||
|
@ -186,11 +186,11 @@ class RuleSetGenerator
|
||||||
|
|
||||||
while (!$workQueue->isEmpty()) {
|
while (!$workQueue->isEmpty()) {
|
||||||
$package = $workQueue->dequeue();
|
$package = $workQueue->dequeue();
|
||||||
if (isset($this->addedMap[$package->getId()])) {
|
if (isset($this->addedMap[$package->id])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addedMap[$package->getId()] = true;
|
$this->addedMap[$package->id] = true;
|
||||||
|
|
||||||
foreach ($package->getRequires() as $link) {
|
foreach ($package->getRequires() as $link) {
|
||||||
if ($ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
|
if ($ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
|
||||||
|
@ -215,7 +215,7 @@ class RuleSetGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
// check obsoletes and implicit obsoletes of a package
|
// check obsoletes and implicit obsoletes of a package
|
||||||
$isInstalled = (isset($this->installedMap[$package->getId()]));
|
$isInstalled = (isset($this->installedMap[$package->id]));
|
||||||
|
|
||||||
foreach ($package->getReplaces() as $link) {
|
foreach ($package->getReplaces() as $link) {
|
||||||
$obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
$obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
||||||
|
@ -289,7 +289,7 @@ class RuleSetGenerator
|
||||||
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
|
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
|
||||||
if ($packages) {
|
if ($packages) {
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
if (!isset($this->installedMap[$package->getId()])) {
|
if (!isset($this->installedMap[$package->id])) {
|
||||||
$this->addRulesForPackage($package, $ignorePlatformReqs);
|
$this->addRulesForPackage($package, $ignorePlatformReqs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Solver
|
||||||
{
|
{
|
||||||
$this->installedMap = array();
|
$this->installedMap = array();
|
||||||
foreach ($this->installed->getPackages() as $package) {
|
foreach ($this->installed->getPackages() as $package) {
|
||||||
$this->installedMap[$package->getId()] = $package;
|
$this->installedMap[$package->id] = $package;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,15 +136,15 @@ class Solver
|
||||||
case 'update':
|
case 'update':
|
||||||
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
|
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
if (isset($this->installedMap[$package->getId()])) {
|
if (isset($this->installedMap[$package->id])) {
|
||||||
$this->updateMap[$package->getId()] = true;
|
$this->updateMap[$package->id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update-all':
|
case 'update-all':
|
||||||
foreach ($this->installedMap as $package) {
|
foreach ($this->installedMap as $package) {
|
||||||
$this->updateMap[$package->getId()] = true;
|
$this->updateMap[$package->id] = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Transaction
|
||||||
$package = $this->pool->literalToPackage($literal);
|
$package = $this->pool->literalToPackage($literal);
|
||||||
|
|
||||||
// wanted & installed || !wanted & !installed
|
// wanted & installed || !wanted & !installed
|
||||||
if (($literal > 0) == (isset($this->installedMap[$package->getId()]))) {
|
if (($literal > 0) == (isset($this->installedMap[$package->id]))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class Transaction
|
||||||
if (isset($installMeansUpdateMap[abs($literal)]) && !$package instanceof AliasPackage) {
|
if (isset($installMeansUpdateMap[abs($literal)]) && !$package instanceof AliasPackage) {
|
||||||
$source = $installMeansUpdateMap[abs($literal)];
|
$source = $installMeansUpdateMap[abs($literal)];
|
||||||
|
|
||||||
$updateMap[$package->getId()] = array(
|
$updateMap[$package->id] = array(
|
||||||
'package' => $package,
|
'package' => $package,
|
||||||
'source' => $source,
|
'source' => $source,
|
||||||
'reason' => $reason,
|
'reason' => $reason,
|
||||||
|
@ -65,9 +65,9 @@ class Transaction
|
||||||
|
|
||||||
// avoid updates to one package from multiple origins
|
// avoid updates to one package from multiple origins
|
||||||
unset($installMeansUpdateMap[abs($literal)]);
|
unset($installMeansUpdateMap[abs($literal)]);
|
||||||
$ignoreRemove[$source->getId()] = true;
|
$ignoreRemove[$source->id] = true;
|
||||||
} else {
|
} else {
|
||||||
$installMap[$package->getId()] = array(
|
$installMap[$package->id] = array(
|
||||||
'package' => $package,
|
'package' => $package,
|
||||||
'reason' => $reason,
|
'reason' => $reason,
|
||||||
);
|
);
|
||||||
|
@ -81,9 +81,9 @@ class Transaction
|
||||||
$package = $this->pool->literalToPackage($literal);
|
$package = $this->pool->literalToPackage($literal);
|
||||||
|
|
||||||
if ($literal <= 0 &&
|
if ($literal <= 0 &&
|
||||||
isset($this->installedMap[$package->getId()]) &&
|
isset($this->installedMap[$package->id]) &&
|
||||||
!isset($ignoreRemove[$package->getId()])) {
|
!isset($ignoreRemove[$package->id])) {
|
||||||
$uninstallMap[$package->getId()] = array(
|
$uninstallMap[$package->id] = array(
|
||||||
'package' => $package,
|
'package' => $package,
|
||||||
'reason' => $reason,
|
'reason' => $reason,
|
||||||
);
|
);
|
||||||
|
@ -107,7 +107,7 @@ class Transaction
|
||||||
|
|
||||||
while (!empty($queue)) {
|
while (!empty($queue)) {
|
||||||
$package = array_pop($queue);
|
$package = array_pop($queue);
|
||||||
$packageId = $package->getId();
|
$packageId = $package->id;
|
||||||
|
|
||||||
if (!isset($visited[$packageId])) {
|
if (!isset($visited[$packageId])) {
|
||||||
array_push($queue, $package);
|
array_push($queue, $package);
|
||||||
|
@ -124,7 +124,7 @@ class Transaction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$visited[$package->getId()] = true;
|
$visited[$package->id] = true;
|
||||||
} else {
|
} else {
|
||||||
if (isset($installMap[$packageId])) {
|
if (isset($installMap[$packageId])) {
|
||||||
$this->install(
|
$this->install(
|
||||||
|
@ -165,7 +165,7 @@ class Transaction
|
||||||
$possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
$possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
||||||
|
|
||||||
foreach ($possibleRequires as $require) {
|
foreach ($possibleRequires as $require) {
|
||||||
unset($roots[$require->getId()]);
|
unset($roots[$require->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,13 +186,13 @@ class Transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
// !wanted & installed
|
// !wanted & installed
|
||||||
if ($literal <= 0 && isset($this->installedMap[$package->getId()])) {
|
if ($literal <= 0 && isset($this->installedMap[$package->id])) {
|
||||||
$updates = $this->policy->findUpdatePackages($this->pool, $this->installedMap, $package);
|
$updates = $this->policy->findUpdatePackages($this->pool, $this->installedMap, $package);
|
||||||
|
|
||||||
$literals = array($package->getId());
|
$literals = array($package->id);
|
||||||
|
|
||||||
foreach ($updates as $update) {
|
foreach ($updates as $update) {
|
||||||
$literals[] = $update->getId();
|
$literals[] = $update->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($literals as $updateLiteral) {
|
foreach ($literals as $updateLiteral) {
|
||||||
|
|
|
@ -48,9 +48,10 @@ abstract class BasePackage implements PackageInterface
|
||||||
protected $prettyName;
|
protected $prettyName;
|
||||||
|
|
||||||
protected $repository;
|
protected $repository;
|
||||||
protected $id;
|
|
||||||
protected $transportOptions;
|
protected $transportOptions;
|
||||||
|
|
||||||
|
public $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All descendants' constructors should call this parent constructor
|
* All descendants' constructors should call this parent constructor
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue