Only load package info from lock file for fixed packages
As a result some lock file packages are no longer in the pool, so the former installed map, now present map cannot use package ids anymore Need to revisit some more code later to simplify this, todo notes leftpull/7936/head
parent
48ae45e5fe
commit
0ff07015a1
|
@ -76,9 +76,14 @@ class LockTransaction
|
||||||
$package = $this->pool->literalToPackage($literal);
|
$package = $this->pool->literalToPackage($literal);
|
||||||
|
|
||||||
// wanted & !present
|
// wanted & !present
|
||||||
if ($literal > 0 && !isset($this->presentMap[$package->id])) {
|
if ($literal > 0 && !isset($this->presentMap[spl_object_hash($package)])) {
|
||||||
if (isset($lockMeansUpdateMap[abs($literal)]) && !$package instanceof AliasPackage) {
|
if (isset($lockMeansUpdateMap[abs($literal)]) && !$package instanceof AliasPackage) {
|
||||||
$operations[] = new Operation\UpdateOperation($lockMeansUpdateMap[abs($literal)], $package, $reason);
|
// TODO we end up here sometimes because we prefer the remote package now to get up to date metadata
|
||||||
|
// TODO define some level of identity here for what constitutes an update and what can be ignored? new kind of metadata only update?
|
||||||
|
$target = $lockMeansUpdateMap[abs($literal)];
|
||||||
|
if ($package->getName() !== $target->getName() || $package->getVersion() !== $target->getVersion()) {
|
||||||
|
$operations[] = new Operation\UpdateOperation($target, $package, $reason);
|
||||||
|
}
|
||||||
|
|
||||||
// avoid updates to one package from multiple origins
|
// avoid updates to one package from multiple origins
|
||||||
$ignoreRemove[$lockMeansUpdateMap[abs($literal)]->id] = true;
|
$ignoreRemove[$lockMeansUpdateMap[abs($literal)]->id] = true;
|
||||||
|
@ -98,7 +103,7 @@ class LockTransaction
|
||||||
$reason = $decision[Decisions::DECISION_REASON];
|
$reason = $decision[Decisions::DECISION_REASON];
|
||||||
$package = $this->pool->literalToPackage($literal);
|
$package = $this->pool->literalToPackage($literal);
|
||||||
|
|
||||||
if ($literal <= 0 && isset($this->presentMap[$package->id]) && !isset($ignoreRemove[$package->id])) {
|
if ($literal <= 0 && isset($this->presentMap[spl_object_hash($package)]) && !isset($ignoreRemove[$package->id])) {
|
||||||
if ($package instanceof AliasPackage) {
|
if ($package instanceof AliasPackage) {
|
||||||
$operations[] = new Operation\MarkAliasUninstalledOperation($package, $reason);
|
$operations[] = new Operation\MarkAliasUninstalledOperation($package, $reason);
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,29 +168,41 @@ class LockTransaction
|
||||||
{
|
{
|
||||||
$lockMeansUpdateMap = array();
|
$lockMeansUpdateMap = array();
|
||||||
|
|
||||||
|
$packages = array();
|
||||||
|
|
||||||
foreach ($this->decisions as $i => $decision) {
|
foreach ($this->decisions as $i => $decision) {
|
||||||
$literal = $decision[Decisions::DECISION_LITERAL];
|
$literal = $decision[Decisions::DECISION_LITERAL];
|
||||||
$package = $this->pool->literalToPackage($literal);
|
$package = $this->pool->literalToPackage($literal);
|
||||||
|
|
||||||
|
if ($literal <= 0 && isset($this->presentMap[spl_object_hash($package)])) {
|
||||||
|
$packages[spl_object_hash($package)] = $package;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// some locked packages are not in the pool and thus, were not decided at all
|
||||||
|
foreach ($this->presentMap as $package) {
|
||||||
|
if ($package->id === -1) {
|
||||||
|
$packages[spl_object_hash($package)] = $package;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($packages as $package) {
|
||||||
if ($package instanceof AliasPackage) {
|
if ($package instanceof AliasPackage) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !wanted & present
|
// TODO can't we just look at existing rules?
|
||||||
if ($literal <= 0 && isset($this->presentMap[$package->id])) {
|
$updates = $this->policy->findUpdatePackages($this->pool, $package);
|
||||||
// TODO can't we just look at existing rules?
|
|
||||||
$updates = $this->policy->findUpdatePackages($this->pool, $package);
|
|
||||||
|
|
||||||
$literals = array($package->id);
|
$literals = array($package->id);
|
||||||
|
|
||||||
foreach ($updates as $update) {
|
foreach ($updates as $update) {
|
||||||
$literals[] = $update->id;
|
$literals[] = $update->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($literals as $updateLiteral) {
|
foreach ($literals as $updateLiteral) {
|
||||||
if ($updateLiteral !== $literal && !isset($lockMeansUpdateMap[$updateLiteral])) {
|
if (!isset($lockMeansUpdateMap[$updateLiteral])) {
|
||||||
$lockMeansUpdateMap[$updateLiteral] = $package;
|
$lockMeansUpdateMap[$updateLiteral] = $package;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ class PoolBuilder
|
||||||
// TODO can actually use very specific constraint
|
// TODO can actually use very specific constraint
|
||||||
$loadNames[$package->getName()] = null;
|
$loadNames[$package->getName()] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request->getJobs() as $job) {
|
foreach ($request->getJobs() as $job) {
|
||||||
switch ($job['cmd']) {
|
switch ($job['cmd']) {
|
||||||
case 'install':
|
case 'install':
|
||||||
|
@ -67,11 +68,24 @@ class PoolBuilder
|
||||||
// also see the solver-problems.test test case
|
// also see the solver-problems.test test case
|
||||||
$constraint = array_key_exists($job['packageName'], $loadNames) ? null : $job['constraint'];
|
$constraint = array_key_exists($job['packageName'], $loadNames) ? null : $job['constraint'];
|
||||||
$loadNames[$job['packageName']] = $constraint;
|
$loadNames[$job['packageName']] = $constraint;
|
||||||
$this->nameConstraints[$job['packageName']] = $constraint ? new MultiConstraint(array($job['constraint']), false) : null;
|
$this->nameConstraints[$job['packageName']] = $constraint ? new MultiConstraint(array($constraint), false) : null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// packages from the locked repository only get loaded if they are explicitly fixed
|
||||||
|
foreach ($repositories as $key => $repository) {
|
||||||
|
if ($repository === $request->getLockedRepository()) {
|
||||||
|
foreach ($repository->getPackages() as $lockedPackage) {
|
||||||
|
foreach ($request->getFixedPackages() as $package) {
|
||||||
|
if ($package === $lockedPackage) {
|
||||||
|
$loadNames += $this->loadPackage($request, $package, $key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (!empty($loadNames)) {
|
while (!empty($loadNames)) {
|
||||||
$loadIds = array();
|
$loadIds = array();
|
||||||
foreach ($repositories as $key => $repository) {
|
foreach ($repositories as $key => $repository) {
|
||||||
|
@ -86,7 +100,7 @@ class PoolBuilder
|
||||||
|
|
||||||
$newLoadNames = array();
|
$newLoadNames = array();
|
||||||
foreach ($repositories as $key => $repository) {
|
foreach ($repositories as $key => $repository) {
|
||||||
if ($repository instanceof PlatformRepository || $repository instanceof InstalledRepositoryInterface) {
|
if ($repository instanceof PlatformRepository || $repository instanceof InstalledRepositoryInterface || $repository === $request->getLockedRepository()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ class Problem
|
||||||
/**
|
/**
|
||||||
* A human readable textual representation of the problem's reasons
|
* A human readable textual representation of the problem's reasons
|
||||||
*
|
*
|
||||||
* @param array $installedMap A map of all installed packages
|
* @param array $installedMap A map of all present packages
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrettyString(array $installedMap = array(), array $learnedPool = array())
|
public function getPrettyString(array $installedMap = array(), array $learnedPool = array())
|
||||||
|
|
|
@ -85,18 +85,20 @@ class Request
|
||||||
return isset($this->fixedPackages[spl_object_hash($package)]);
|
return isset($this->fixedPackages[spl_object_hash($package)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPresentMap()
|
// TODO look into removing the packageIds option, the only place true is used is for the installed map in the solver problems
|
||||||
|
// some locked packages may not be in the pool so they have a package->id of -1
|
||||||
|
public function getPresentMap($packageIds = false)
|
||||||
{
|
{
|
||||||
$presentMap = array();
|
$presentMap = array();
|
||||||
|
|
||||||
if ($this->lockedRepository) {
|
if ($this->lockedRepository) {
|
||||||
foreach ($this->lockedRepository->getPackages() as $package) {
|
foreach ($this->lockedRepository->getPackages() as $package) {
|
||||||
$presentMap[$package->id] = $package;
|
$presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->fixedPackages as $package) {
|
foreach ($this->fixedPackages as $package) {
|
||||||
$presentMap[$package->id] = $package;
|
$presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $presentMap;
|
return $presentMap;
|
||||||
|
@ -113,7 +115,8 @@ class Request
|
||||||
return $unlockableMap;
|
return $unlockableMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLockMap()
|
public function getLockedRepository()
|
||||||
{
|
{
|
||||||
|
return $this->lockedRepository;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ class Solver
|
||||||
$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);
|
||||||
|
|
||||||
if ($this->problems) {
|
if ($this->problems) {
|
||||||
throw new SolverProblemsException($this->problems, $request->getPresentMap(), $this->learnedPool);
|
throw new SolverProblemsException($this->problems, $request->getPresentMap(true), $this->learnedPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LockTransaction($this->policy, $this->pool, $request->getPresentMap(), $request->getUnlockableMap(), $this->decisions);
|
return new LockTransaction($this->policy, $this->pool, $request->getPresentMap(), $request->getUnlockableMap(), $this->decisions);
|
||||||
|
|
|
@ -52,8 +52,10 @@ update b/b --with-dependencies
|
||||||
<warning>Dependency "a/a" is also a root requirement, but is not explicitly whitelisted. Ignoring.</warning>
|
<warning>Dependency "a/a" is also a root requirement, but is not explicitly whitelisted. Ignoring.</warning>
|
||||||
Loading composer repositories with package information
|
Loading composer repositories with package information
|
||||||
Updating dependencies
|
Updating dependencies
|
||||||
Nothing to install or update
|
Nothing to modify in lock file
|
||||||
Writing lock file
|
Writing lock file
|
||||||
|
Installing dependencies from lock file (including require-dev)
|
||||||
|
Nothing to install, update or remove
|
||||||
Generating autoload files
|
Generating autoload files
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
|
@ -65,7 +65,7 @@ Your requirements could not be resolved to an installable set of packages.
|
||||||
- requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> no matching package found.
|
- requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> no matching package found.
|
||||||
Problem 4
|
Problem 4
|
||||||
- stable-requiree-excluded/pkg is locked to version 1.0.0 and an update of this package was not requested.
|
- 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].
|
- Same name, can only install one of: stable-requiree-excluded/pkg[1.0.1, 1.0.0].
|
||||||
- Installation request for stable-requiree-excluded/pkg 1.0.1 -> satisfiable by stable-requiree-excluded/pkg[1.0.1].
|
- Installation request for stable-requiree-excluded/pkg 1.0.1 -> satisfiable by stable-requiree-excluded/pkg[1.0.1].
|
||||||
|
|
||||||
Potential causes:
|
Potential causes:
|
||||||
|
|
Loading…
Reference in New Issue