Merge pull request #8376 from aschempp/bugfix/why-replaces
Consider replaces when checking package dependentspull/8390/head
commit
127ba941f1
|
@ -67,6 +67,27 @@ abstract class BaseRepository implements RepositoryInterface
|
||||||
// Replacements are considered valid reasons for a package to be installed during forward resolution
|
// Replacements are considered valid reasons for a package to be installed during forward resolution
|
||||||
if (!$invert) {
|
if (!$invert) {
|
||||||
$links += $package->getReplaces();
|
$links += $package->getReplaces();
|
||||||
|
|
||||||
|
// On forward search, check if any replaced package was required and add the replaced
|
||||||
|
// packages to the list of needles. Contrary to the cross-reference link check below,
|
||||||
|
// replaced packages are the target of links.
|
||||||
|
foreach ($package->getReplaces() as $link) {
|
||||||
|
foreach ($needles as $needle) {
|
||||||
|
if ($link->getSource() === $needle) {
|
||||||
|
if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
|
||||||
|
// already displayed this node's dependencies, cutting short
|
||||||
|
if (in_array($link->getTarget(), $packagesInTree)) {
|
||||||
|
$results[] = array($package, $link, false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$packagesInTree[] = $link->getTarget();
|
||||||
|
$dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
|
||||||
|
$results[] = array($package, $link, $dependents);
|
||||||
|
$needles[] = $link->getTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require-dev is only relevant for the root package
|
// Require-dev is only relevant for the root package
|
||||||
|
@ -81,12 +102,12 @@ abstract class BaseRepository implements RepositoryInterface
|
||||||
if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
|
if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
|
||||||
// already displayed this node's dependencies, cutting short
|
// already displayed this node's dependencies, cutting short
|
||||||
if (in_array($link->getSource(), $packagesInTree)) {
|
if (in_array($link->getSource(), $packagesInTree)) {
|
||||||
$results[$link->getSource()] = array($package, $link, false);
|
$results[] = array($package, $link, false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$packagesInTree[] = $link->getSource();
|
$packagesInTree[] = $link->getSource();
|
||||||
$dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
|
$dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
|
||||||
$results[$link->getSource()] = array($package, $link, $dependents);
|
$results[] = array($package, $link, $dependents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue