1
0
Fork 0

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

* Fix handling of upper-bound platform req ignores to not act on conflicts, fixes #11020

* Optimization
pull/11057/head
Jordi Boggiano 2022-09-13 14:50:27 +02:00 committed by GitHub
parent 4164b30236
commit ab29ed5f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -223,7 +223,7 @@ class RuleSetGenerator
if ($platformRequirementFilter->isIgnored($link->getTarget())) { if ($platformRequirementFilter->isIgnored($link->getTarget())) {
continue; continue;
} elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) { } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
$constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint); $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint, false);
} }
$conflicts = $this->pool->whatProvides($link->getTarget(), $constraint); $conflicts = $this->pool->whatProvides($link->getTarget(), $constraint);

View File

@ -60,13 +60,16 @@ final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFi
return Preg::isMatch($this->ignoreRegex, $req); 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)) { if (!PlatformRepository::isPlatformPackage($req)) {
return $constraint; return $constraint;
} }
if (!Preg::isMatch($this->ignoreUpperBoundRegex, $req)) { if (!$allowUpperBoundOverride || !Preg::isMatch($this->ignoreUpperBoundRegex, $req)) {
return $constraint; return $constraint;
} }

View File

@ -7,13 +7,15 @@ Update with ignore-platform-req list ignoring upper bound of a dependency
"type": "package", "type": "package",
"package": [ "package": [
{ "name": "a/a", "version": "1.0.1", "require": { "ext-foo-bar": "3.*" } }, { "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": { "require": {
"a/a": "1.0.*", "a/a": "1.0.*",
"b/b": "1.0.*", "b/b": "1.0.*",
"c/c": "1.0.*",
"php": "^4.3", "php": "^4.3",
"ext-foo-baz": "9.0.0" "ext-foo-baz": "9.0.0"
}, },