1
0
Fork 0

Fix finding replacers/providers to check constraints correctly

pull/8669/head
Jordi Boggiano 2020-02-17 11:23:15 +01:00
parent 2e82e34fe0
commit 20e4cc3b6f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 12 additions and 1 deletions

View File

@ -44,8 +44,19 @@ class InstalledRepository extends CompositeRepository
foreach ($this->getRepositories() as $repo) { foreach ($this->getRepositories() as $repo) {
foreach ($repo->getPackages() as $candidate) { foreach ($repo->getPackages() as $candidate) {
if (in_array($name, $candidate->getNames(), true)) { if (in_array($name, $candidate->getNames(), true)) {
if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) { if (null === $constraint) {
$matches[] = $candidate; $matches[] = $candidate;
continue;
}
if ($name === $candidate->getName() && $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
$matches[] = $candidate;
continue;
}
foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
if ($name === $link->getTarget() && ($link->getConstraint() === null || $constraint->matches($link->getConstraint()))) {
$matches[] = $candidate;
continue;
}
} }
} }
} }