1
0
Fork 0

Allow an install request for a package name which is already fixed

Ensures packages get loaded from locked repo correctly. We may not want
to support this particular use-case at all, but for now it fixes the
existing test, so we may want to revisit this later.
pull/7936/head
Nils Adermann 2019-10-29 22:28:36 +01:00
parent 995b4f923e
commit 4481cc4a88
6 changed files with 18 additions and 12 deletions

View File

@ -62,8 +62,12 @@ class PoolBuilder
foreach ($request->getJobs() as $job) {
switch ($job['cmd']) {
case 'install':
$loadNames[$job['packageName']] = $job['constraint'];
$this->nameConstraints[$job['packageName']] = $job['constraint'] ? new MultiConstraint(array($job['constraint']), false) : null;
// TODO currently lock above is always NULL if we adjust that, this needs to merge constraints
// TODO does it really make sense that we can have install requests for the same package that is actively locked with non-matching constraints?
// also see the solver-problems.test test case
$constraint = array_key_exists($job['packageName'], $loadNames) ? null : $job['constraint'];
$loadNames[$job['packageName']] = $constraint;
$this->nameConstraints[$job['packageName']] = $constraint ? new MultiConstraint(array($job['constraint']), false) : null;
break;
}
}
@ -199,6 +203,7 @@ class PoolBuilder
// TODO addConstraint function?
$this->nameConstraints[$require] = new MultiConstraint(array_merge(array($linkConstraint), $this->nameConstraints[$require]->getConstraints()), false);
}
// else it is null and should stay null
} else {
$this->nameConstraints[$require] = null;
}

View File

@ -211,10 +211,10 @@ class Problem
case 'fix':
$package = $job['package'];
if ($job['lockable']) {
return 'Package '.$package->getPrettyName().' is locked to version '.$package->getPrettyVersion();
} else {
return 'Package '.$package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
}
return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
case 'install':
$packages = $this->pool->whatProvides($packageName, $constraint);
if (!$packages) {

View File

@ -261,6 +261,10 @@ class RuleSetGenerator
$unlockableMap = $request->getUnlockableMap();
foreach ($request->getFixedPackages() as $package) {
if ($package->id == -1) {
throw new \RuntimeException("Fixed package ".$package->getName()." was not added to solver pool.");
}
$this->addRulesForPackage($package, $ignorePlatformReqs);
$rule = $this->createInstallOneOfRule(array($package), Rule::RULE_JOB_INSTALL, array(

View File

@ -147,7 +147,6 @@ class Solver
if (abs($literal) !== abs($assertRuleLiteral)) {
continue;
}
$problem->addRule($assertRule);
$this->disableProblem($assertRule);
}

View File

@ -523,8 +523,6 @@ class Installer
return array();
}
;
$resultRepo = new ArrayRepository(array());
$loader = new ArrayLoader(null, true);
$dumper = new ArrayDumper();

View File

@ -61,12 +61,12 @@ Your requirements could not be resolved to an installable set of packages.
Problem 2
- The requested package bogus/pkg could not be found in any version, there may be a typo in the package name.
Problem 3
- The requested package stable-requiree-excluded/pkg 1.0.1 exists as stable-requiree-excluded/pkg[1.0.0] but these are rejected by your constraint.
Problem 4
- The requested package stable-requiree-excluded/pkg (installed at 1.0.0, required as 1.0.1) is satisfiable by stable-requiree-excluded/pkg[1.0.0] but these conflict with your requirements or minimum-stability.
Problem 5
- Installation request for requirer/pkg 1.* -> satisfiable by requirer/pkg[1.0.0].
- requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> no matching package found.
Problem 4
- stable-requiree-excluded/pkg is locked to version 1.0.0 and an update of this package was not requested.
- Same name, can only install one of: stable-requiree-excluded/pkg[1.0.0, 1.0.1].
- Installation request for stable-requiree-excluded/pkg 1.0.1 -> satisfiable by stable-requiree-excluded/pkg[1.0.1].
Potential causes:
- A typo in the package name