1
0
Fork 0

Use spl_object_hash() instead of the package id which doesn't exist anymore

pull/1/head
Jordi Boggiano 2011-05-22 09:05:24 +02:00
parent b85c1a2780
commit 831f5219b6
2 changed files with 23 additions and 18 deletions

View File

@ -39,12 +39,12 @@ class Literal
public function getPackageId() public function getPackageId()
{ {
return $this->package->getId(); return spl_object_hash($this->package);
} }
public function getId() public function getId()
{ {
return (($this->wanted) ? 1 : -1) * $this->package->getId(); return (($this->wanted) ? 1 : -1) * spl_object_hash($this->package);
} }
public function __toString() public function __toString()

View File

@ -251,14 +251,14 @@ class Solver
while (!$workQueue->isEmpty()) { while (!$workQueue->isEmpty()) {
$package = $workQueue->dequeue(); $package = $workQueue->dequeue();
if (isset($this->addedMap[$package->getId()])) { if (isset($this->addedMap[$this->getId($package)])) {
continue; continue;
} }
$this->addedMap[$package->getId()] = true; $this->addedMap[$this->getId($package)] = true;
$dontFix = 0; $dontFix = 0;
if ($this->installed === $package->getRepository() && !isset($this->fixMap[$package->getId()])) { if ($this->installed === $package->getRepository() && !isset($this->fixMap[$this->getId($package)])) {
$dontFix = 1; $dontFix = 1;
} }
@ -451,13 +451,13 @@ class Solver
switch ($job['cmd']) { switch ($job['cmd']) {
case 'update-all': case 'update-all':
foreach ($installedPackages as $package) { foreach ($installedPackages as $package) {
$this->updateMap[$package->getId()] = true; $this->updateMap[$this->getId($package)] = true;
} }
break; break;
case 'fix-all': case 'fix-all':
foreach ($installedPackages as $package) { foreach ($installedPackages as $package) {
$this->fixMap[$package->getId()] = true; $this->fixMap[$this->getId($package)] = true;
} }
break; break;
} }
@ -466,12 +466,12 @@ class Solver
switch ($job['cmd']) { switch ($job['cmd']) {
case 'fix': case 'fix':
if ($this->installed === $package->getRepository()) { if ($this->installed === $package->getRepository()) {
$this->fixMap[$package->getId()] = true; $this->fixMap[$this->getId($package)] = true;
} }
break; break;
case 'update': case 'update':
if ($this->installed === $package->getRepository()) { if ($this->installed === $package->getRepository()) {
$this->updateMap[$package->getId()] = true; $this->updateMap[$this->getId($package)] = true;
} }
break; break;
} }
@ -491,7 +491,7 @@ class Solver
foreach ($job['packages'] as $package) { foreach ($job['packages'] as $package) {
switch ($job['cmd']) { switch ($job['cmd']) {
case 'install': case 'install':
$this->installCandidateMap[$package->getId()] = true; $this->installCandidateMap[$this->getId($package)] = true;
$this->addRulesForPackage($package); $this->addRulesForPackage($package);
break; break;
} }
@ -646,22 +646,22 @@ class Solver
)); ));
} }
protected function decided(Package $p) protected function decided(PackageInterface $package)
{ {
return isset($this->decisionMap[$p->getId()]); return isset($this->decisionMap[$this->getId($package)]);
} }
protected function undecided(Package $p) protected function undecided(PackageInterface $package)
{ {
return !isset($this->decisionMap[$p->getId()]); return !isset($this->decisionMap[$this->getId($package)]);
} }
protected function decidedInstall(Package $p) { protected function decidedInstall(PackageInterface $package) {
return isset($this->decisionMap[$p->getId()]) && $this->decisionMap[$p->getId()] > 0; return isset($this->decisionMap[$this->getId($package)]) && $this->decisionMap[$this->getId($package)] > 0;
} }
protected function decidedRemove(Package $p) { protected function decidedRemove(PackageInterface $package) {
return isset($this->decisionMap[$p->getId()]) && $this->decisionMap[$p->getId()] < 0; return isset($this->decisionMap[$this->getId($package)]) && $this->decisionMap[$this->getId($package)] < 0;
} }
/** /**
@ -735,6 +735,11 @@ class Solver
return null; return null;
} }
private function getId($package)
{
return spl_object_hash($package);
}
private function setPropagateLearn($level, Literal $literal, $disableRules, Rule $rule) private function setPropagateLearn($level, Literal $literal, $disableRules, Rule $rule)
{ {
return 0; return 0;