Skip to content

Commit 21937a8

Browse files
bug #1048 Fix needless call to flex API on composer i (nicolas-grekas)
This PR was merged into the 2.x branch. Discussion ---------- Fix needless call to flex API on composer i Fix #1040 Commits ------- cfe894c Fix needless call to flex API on composer i
2 parents 5f92875 + cfe894c commit 21937a8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/PackageFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function removeLegacyPackages(array $data, RootPackageInterface $rootPack
6565
$rootConstraints[$name] = $link->getConstraint();
6666
}
6767

68-
$knownVersions = $this->getVersions();
68+
$knownVersions = null;
6969
$filteredPackages = [];
7070
$symfonyPackages = [];
7171
$oneSymfony = false;
@@ -77,8 +77,8 @@ public function removeLegacyPackages(array $data, RootPackageInterface $rootPack
7777
}
7878

7979
if ('symfony/symfony' !== $name && (
80-
!isset($knownVersions['splits'][$name])
81-
|| array_intersect($versions, $lockedVersions[$name] ?? [])
80+
array_intersect($versions, $lockedVersions[$name] ?? [])
81+
|| (($knownVersions ??= $this->getVersions()) && !isset($knownVersions['splits'][$name]))
8282
|| (isset($rootConstraints[$name]) && !Intervals::haveIntersections($this->symfonyConstraints, $rootConstraints[$name]))
8383
|| ('symfony/psr-http-message-bridge' === $name && 6.4 > $versions[0])
8484
)) {

tests/PackageFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PackageFilterTest extends TestCase
3232
public function testRemoveLegacyPackages(array $expected, array $packages, string $symfonyRequire, array $versions, array $lockedPackages = [])
3333
{
3434
$downloader = $this->getMockBuilder('Symfony\Flex\Downloader')->disableOriginalConstructor()->getMock();
35-
$downloader->expects($this->once())
35+
$downloader->expects($this->any())
3636
->method('getVersions')
3737
->willReturn($versions);
3838
$filter = new PackageFilter(new NullIO(), $symfonyRequire, $downloader);

0 commit comments

Comments
 (0)