Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ceac19

Browse files
committed
Fix Pool problem message produces invalid paths
1 parent 8019caa commit 2ceac19

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

src/Composer/DependencyResolver/Problem.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,11 @@ public static function getMissingPackageReason(RepositorySet $repositorySet, Req
418418

419419
if ($pool->isFilterListRemovedPackageVersion($packageName, $constraint)) {
420420
$filters = $pool->getFilterListEntryForPackageVersion($packageName, $constraint);
421+
$ignorePaths = implode(' and ', array_map(static function (string $listName): string {
422+
return '"policy.' . $listName . '.ignore"';
423+
}, array_keys($filters)));
421424

422-
return ["- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but these were not loaded, because they were ' . implode(', ', $filters). '. To ignore filters for this package, add the package to the "policy.' . implode('|', array_keys($filters)). '.ignore" config. To turn the feature off entirely, you can set "policy" to false.'];
425+
return ["- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but these were not loaded, because they were ' . implode(', ', $filters). '. To ignore filters for this package, add the package to the ' . $ignorePaths . ' config. To turn the feature off entirely, you can set "policy" to false.'];
423426
}
424427

425428
return ["- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but these were not loaded, likely because '.(self::hasMultipleNames($packages) ? 'they conflict' : 'it conflicts').' with another require.'];
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
--TEST--
2+
Filter list entries from multiple lists matching a direct dependency suggest one ignore path per list.
3+
--COMPOSER--
4+
{
5+
"name": "acme/project",
6+
"version": "1.0.0",
7+
"require": {
8+
"acme/library": "1.0.0"
9+
},
10+
"config": {
11+
"policy": {
12+
"test-list": true
13+
}
14+
},
15+
"repositories": [
16+
{
17+
"type": "package",
18+
"package": [
19+
{
20+
"name": "acme/library",
21+
"version": "1.0.0",
22+
"source": { "reference": "some.branch", "type": "git", "url": "" }
23+
}
24+
],
25+
"filter": {
26+
"malware": [
27+
{
28+
"package": "acme/library",
29+
"constraint": "*",
30+
"url": "https://example.org/malware/acme/library",
31+
"reason": "malware",
32+
"id": "ID-malware"
33+
}
34+
],
35+
"test-list": [
36+
{
37+
"package": "acme/library",
38+
"constraint": "*",
39+
"url": "https://example.org/test-list/acme/library",
40+
"reason": "policy violation",
41+
"id": "ID-test"
42+
}
43+
]
44+
}
45+
}
46+
]
47+
}
48+
--RUN--
49+
update -v
50+
51+
--EXPECT-EXIT-CODE--
52+
2
53+
54+
--EXPECT-OUTPUT--
55+
Loading composer repositories with package information
56+
Updating dependencies
57+
Your requirements could not be resolved to an installable set of packages.
58+
59+
Problem 1
60+
- Root composer.json requires acme/library 1.0.0 (exact version match: 1.0.0 or 1.0.0.0), found acme/library[1.0.0] but these were not loaded, because they were flagged as malware (see https://example.org/malware/acme/library) reason: malware, filtered by test-list (see https://example.org/test-list/acme/library) reason: policy violation. To ignore filters for this package, add the package to the "policy.malware.ignore" and "policy.test-list.ignore" config. To turn the feature off entirely, you can set "policy" to false.
61+
62+
--EXPECT--

0 commit comments

Comments
 (0)