Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of upper-bound platform req ignores to not act on conflicts #11037

Merged
merged 2 commits into from Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Composer/DependencyResolver/RuleSetGenerator.php
Expand Up @@ -223,7 +223,7 @@ protected function addConflictRules(PlatformRequirementFilterInterface $platform
if ($platformRequirementFilter->isIgnored($link->getTarget())) {
continue;
} elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
$constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint);
$constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint, false);
}

$conflicts = $this->pool->whatProvides($link->getTarget(), $constraint);
Expand Down
Expand Up @@ -60,13 +60,16 @@ public function isIgnored(string $req): bool
return Preg::isMatch($this->ignoreRegex, $req);
}

public function filterConstraint(string $req, ConstraintInterface $constraint): ConstraintInterface
/**
* @param bool $allowUpperBoundOverride For conflicts we do not want the upper bound to be skipped
*/
public function filterConstraint(string $req, ConstraintInterface $constraint, bool $allowUpperBoundOverride = true): ConstraintInterface
{
if (!PlatformRepository::isPlatformPackage($req)) {
return $constraint;
}

if (!Preg::isMatch($this->ignoreUpperBoundRegex, $req)) {
if (!$allowUpperBoundOverride || !Preg::isMatch($this->ignoreUpperBoundRegex, $req)) {
return $constraint;
}

Expand Down
Expand Up @@ -7,13 +7,15 @@ Update with ignore-platform-req list ignoring upper bound of a dependency
"type": "package",
"package": [
{ "name": "a/a", "version": "1.0.1", "require": { "ext-foo-bar": "3.*" } },
{ "name": "b/b", "version": "1.0.1", "require": { "ext-foo-bar": "10.*" } }
{ "name": "b/b", "version": "1.0.1", "require": { "ext-foo-bar": "10.*" } },
{ "name": "c/c", "version": "1.0.1", "conflict": { "ext-foo-bar": "4.0.0 - 4.0.2", "php": "3.0.*" } }
]
}
],
"require": {
"a/a": "1.0.*",
"b/b": "1.0.*",
"c/c": "1.0.*",
"php": "^4.3",
"ext-foo-baz": "9.0.0"
},
Expand Down