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

Skip to content

Commit 381997b

Browse files
committed
FilterList: fix problem message
1 parent a03d365 commit 381997b

9 files changed

Lines changed: 23 additions & 15 deletions

src/Composer/DependencyResolver/Pool.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,26 @@ public function getAllFilterListRemovedPackageVersions(): array
196196
*/
197197
public function getFilterListEntryForPackageVersion(string $packageName, ?ConstraintInterface $constraint): array
198198
{
199+
$lists = [];
199200
foreach ($this->filterListRemovedVersions[$packageName] ?? [] as $version => $filterListEntries) {
200201
if ($constraint !== null && $constraint->matches(new Constraint('==', $version))) {
201-
return array_map(static function (FilterListEntry $entry) {
202-
$url = (bool) $entry->url ? ' (see ' . $entry->url . ')' : '';
203-
$reason = (bool) $entry->reason ? ' reason: ' . $entry->reason . '' : '';
202+
foreach ($filterListEntries as $entry) {
203+
$url = $entry->url ? ' (see ' . $entry->url . ')' : '';
204+
$reason = $entry->reason ? ' reason: ' . $entry->reason : '';
205+
206+
$lists[$entry->listName][] = $url . $reason;
207+
}
204208

205-
return 'filtered by ' . $entry->listName . $url . $reason;
206-
}, $filterListEntries);
207209
}
208210
}
209211

210-
return [];
212+
$result = [];
213+
foreach ($lists as $listName => $listEntries) {
214+
$action = $listName === 'malware' ? 'flagged as ' : 'filtered by ';
215+
$result[$listName] = $action . $listName . implode(', ', $listEntries);
216+
}
217+
218+
return $result;
211219
}
212220

213221
/**

src/Composer/DependencyResolver/Problem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public static function getMissingPackageReason(RepositorySet $repositorySet, Req
419419
if ($pool->isFilterListRemovedPackageVersion($packageName, $constraint)) {
420420
$filters = $pool->getFilterListEntryForPackageVersion($packageName, $constraint);
421421

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 "filter.unfiltered-packages" config. To turn the feature off entirely, you can set "filter" to false.'];
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.'];
423423
}
424424

425425
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.'];

tests/Composer/Test/Fixtures/installer/update-policy-advisory-matching-direct-dependency.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Security advisory matching direct dependency preventing a successful update.
2+
Security advisory policy matching direct dependency preventing a successful update.
33
--COMPOSER--
44
{
55
"name": "acme/project",

tests/Composer/Test/Fixtures/installer/update-policy-advisory-matching-indirect-dependency.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Security advisory matching indirect dependency preventing a successful update.
2+
Security advisory policy matching indirect dependency preventing a successful update.
33
--COMPOSER--
44
{
55
"name": "acme/project",

tests/Composer/Test/Fixtures/installer/update-policy-filter-entry-list-ignore-not-on-block.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Filter list entry matching direct dependency preventing a successful update.
2+
Filter list entry matching direct dependency with ignore on-block=false preventing a successful update.
33
--COMPOSER--
44
{
55
"name": "acme/project",
@@ -57,7 +57,7 @@ Updating dependencies
5757
Your requirements could not be resolved to an installable set of packages.
5858

5959
Problem 1
60-
- Root composer.json requires acme/library ^1.0.0, found acme/library[1.0.0, 1.1.0] but these were not loaded, because they were filtered by test-list (see https://example.org/malware/acme/library) reason: malware. To ignore filters for this package, add the package to the "filter.unfiltered-packages" config. To turn the feature off entirely, you can set "filter" to false.
60+
- Root composer.json requires acme/library ^1.0.0, found acme/library[1.0.0, 1.1.0] but these were not loaded, because they were filtered by test-list (see https://example.org/malware/acme/library) reason: malware, (see https://example.org/malware/acme/library) reason: malware. To ignore filters for this package, add the package to the "policy.test-list.ignore" config. To turn the feature off entirely, you can set "policy" to false.
6161

6262

6363
--EXPECT--

tests/Composer/Test/Fixtures/installer/update-policy-filter-entry-list-ignore.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Filter list entry matching direct dependency preventing a successful update.
2+
Filter list entry matching direct dependency not preventing a successful update because pacakge version is ignored.
33
--COMPOSER--
44
{
55
"name": "acme/project",

tests/Composer/Test/Fixtures/installer/update-policy-filter-entry-list-not-blocking.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Filter list entry matching direct dependency preventing a successful update.
2+
Filter list entry matching direct dependency not preventing a successful update because block is set to false.
33
--COMPOSER--
44
{
55
"name": "acme/project",

tests/Composer/Test/Fixtures/installer/update-policy-filter-entry-matching-direct-dependency.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ Updating dependencies
4848
Your requirements could not be resolved to an installable set of packages.
4949

5050
Problem 1
51-
- 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 filtered by test-list (see https://example.org/malware/acme/library) reason: malware. To ignore filters for this package, add the package to the "filter.unfiltered-packages" config. To turn the feature off entirely, you can set "filter" to false.
51+
- 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 filtered by test-list (see https://example.org/malware/acme/library) reason: malware. To ignore filters for this package, add the package to the "policy.test-list.ignore" config. To turn the feature off entirely, you can set "policy" to false.
5252

5353
--EXPECT--

tests/Composer/Test/Fixtures/installer/update-policy-malware-entry-matching-direct-dependency.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ Updating dependencies
4444
Your requirements could not be resolved to an installable set of packages.
4545

4646
Problem 1
47-
- 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 filtered by malware (see https://example.org/malware/acme/library) reason: malware. To ignore filters for this package, add the package to the "filter.unfiltered-packages" config. To turn the feature off entirely, you can set "filter" to false.
47+
- 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. To ignore filters for this package, add the package to the "policy.malware.ignore" config. To turn the feature off entirely, you can set "policy" to false.
4848

4949
--EXPECT--

0 commit comments

Comments
 (0)