Remove disableRules code from Solver, leftover from original C code
This goes back to an input option to install recommended packages, which would in turn allow removal of these packages if that was needed to resolve the rest. This was supported in very early versions of Composer with suggested packages. We later realized this was not useful in the context of a project based dependency manager with a lock file, so it was removed but the solver was never cleaned up.pull/8424/head
parent
c325112670
commit
6f9b1e76e3
|
@ -213,7 +213,7 @@ class Solver
|
||||||
|
|
||||||
$this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
|
$this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
|
||||||
$before = microtime(true);
|
$before = microtime(true);
|
||||||
$this->runSat(true);
|
$this->runSat();
|
||||||
$this->io->writeError('', true, IOInterface::DEBUG);
|
$this->io->writeError('', true, IOInterface::DEBUG);
|
||||||
$this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
|
$this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
|
||||||
|
|
||||||
|
@ -298,11 +298,10 @@ class Solver
|
||||||
*
|
*
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @param string|int $literal
|
* @param string|int $literal
|
||||||
* @param bool $disableRules
|
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function setPropagateLearn($level, $literal, $disableRules, Rule $rule)
|
private function setPropagateLearn($level, $literal, Rule $rule)
|
||||||
{
|
{
|
||||||
$level++;
|
$level++;
|
||||||
|
|
||||||
|
@ -316,7 +315,7 @@ class Solver
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($level == 1) {
|
if ($level == 1) {
|
||||||
return $this->analyzeUnsolvable($rule, $disableRules);
|
return $this->analyzeUnsolvable($rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
// conflict
|
// conflict
|
||||||
|
@ -353,11 +352,10 @@ class Solver
|
||||||
/**
|
/**
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @param array $decisionQueue
|
* @param array $decisionQueue
|
||||||
* @param bool $disableRules
|
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function selectAndInstall($level, array $decisionQueue, $disableRules, Rule $rule)
|
private function selectAndInstall($level, array $decisionQueue, Rule $rule)
|
||||||
{
|
{
|
||||||
// choose best package to install from decisionQueue
|
// choose best package to install from decisionQueue
|
||||||
$literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
|
$literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
|
||||||
|
@ -369,7 +367,7 @@ class Solver
|
||||||
$this->branches[] = array($literals, $level);
|
$this->branches[] = array($literals, $level);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->setPropagateLearn($level, $selectedLiteral, $disableRules, $rule);
|
return $this->setPropagateLearn($level, $selectedLiteral, $rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -515,10 +513,9 @@ class Solver
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Rule $conflictRule
|
* @param Rule $conflictRule
|
||||||
* @param bool $disableRules
|
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function analyzeUnsolvable(Rule $conflictRule, $disableRules)
|
private function analyzeUnsolvable(Rule $conflictRule)
|
||||||
{
|
{
|
||||||
$problem = new Problem($this->pool);
|
$problem = new Problem($this->pool);
|
||||||
$problem->addRule($conflictRule);
|
$problem->addRule($conflictRule);
|
||||||
|
@ -562,16 +559,6 @@ class Solver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($disableRules) {
|
|
||||||
foreach ($this->problems[count($this->problems) - 1] as $reason) {
|
|
||||||
$this->disableProblem($reason['rule']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->resetSolver();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,10 +624,7 @@ class Solver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function runSat()
|
||||||
* @param bool $disableRules
|
|
||||||
*/
|
|
||||||
private function runSat($disableRules = true)
|
|
||||||
{
|
{
|
||||||
$this->propagateIndex = 0;
|
$this->propagateIndex = 0;
|
||||||
|
|
||||||
|
@ -656,10 +640,6 @@ class Solver
|
||||||
|
|
||||||
$decisionQueue = array();
|
$decisionQueue = array();
|
||||||
$decisionSupplementQueue = array();
|
$decisionSupplementQueue = array();
|
||||||
/**
|
|
||||||
* @todo this makes $disableRules always false; determine the rationale and possibly remove dead code?
|
|
||||||
*/
|
|
||||||
$disableRules = false;
|
|
||||||
|
|
||||||
$level = 1;
|
$level = 1;
|
||||||
$systemLevel = $level + 1;
|
$systemLevel = $level + 1;
|
||||||
|
@ -669,7 +649,7 @@ class Solver
|
||||||
if (1 === $level) {
|
if (1 === $level) {
|
||||||
$conflictRule = $this->propagate($level);
|
$conflictRule = $this->propagate($level);
|
||||||
if (null !== $conflictRule) {
|
if (null !== $conflictRule) {
|
||||||
if ($this->analyzeUnsolvable($conflictRule, $disableRules)) {
|
if ($this->analyzeUnsolvable($conflictRule)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +690,7 @@ class Solver
|
||||||
|
|
||||||
if ($noneSatisfied && count($decisionQueue)) {
|
if ($noneSatisfied && count($decisionQueue)) {
|
||||||
$oLevel = $level;
|
$oLevel = $level;
|
||||||
$level = $this->selectAndInstall($level, $decisionQueue, $disableRules, $rule);
|
$level = $this->selectAndInstall($level, $decisionQueue, $rule);
|
||||||
|
|
||||||
if (0 === $level) {
|
if (0 === $level) {
|
||||||
return;
|
return;
|
||||||
|
@ -786,7 +766,7 @@ class Solver
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$level = $this->selectAndInstall($level, $decisionQueue, $disableRules, $rule);
|
$level = $this->selectAndInstall($level, $decisionQueue, $rule);
|
||||||
|
|
||||||
if (0 === $level) {
|
if (0 === $level) {
|
||||||
return;
|
return;
|
||||||
|
@ -829,7 +809,7 @@ class Solver
|
||||||
|
|
||||||
$why = $this->decisions->lastReason();
|
$why = $this->decisions->lastReason();
|
||||||
|
|
||||||
$level = $this->setPropagateLearn($level, $lastLiteral, $disableRules, $why);
|
$level = $this->setPropagateLearn($level, $lastLiteral, $why);
|
||||||
|
|
||||||
if ($level == 0) {
|
if ($level == 0) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue