@@ -46,9 +46,11 @@ class Downloader
46
46
private $ degradedMode = false ;
47
47
private $ endpoints ;
48
48
private $ index ;
49
+ private $ conflicts ;
49
50
private $ legacyEndpoint ;
50
51
private $ caFile ;
51
52
private $ enabled = true ;
53
+ private $ composer ;
52
54
53
55
public function __construct (Composer $ composer , IoInterface $ io , $ rfs )
54
56
{
@@ -91,6 +93,7 @@ public function __construct(Composer $composer, IoInterface $io, $rfs)
91
93
$ this ->rfs = $ rfs ;
92
94
$ this ->cache = new ComposerCache ($ io , $ config ->get ('cache-repo-dir ' ).'/flex ' );
93
95
$ this ->sess = bin2hex (random_bytes (16 ));
96
+ $ this ->composer = $ composer ;
94
97
}
95
98
96
99
public function getSessionId (): string
@@ -136,6 +139,22 @@ public function getRecipes(array $operations): array
136
139
{
137
140
$ this ->initialize ();
138
141
142
+ if ($ this ->conflicts ) {
143
+ $ lockedRepository = $ this ->composer ->getLocker ()->getLockedRepository ();
144
+ foreach ($ this ->conflicts as $ conflicts ) {
145
+ foreach ($ conflicts as $ package => $ versions ) {
146
+ foreach ($ versions as $ version => $ conflicts ) {
147
+ foreach ($ conflicts as $ conflictingPackage => $ constraint ) {
148
+ if ($ lockedRepository ->findPackage ($ conflictingPackage , $ constraint )) {
149
+ unset($ this ->index [$ package ][$ version ]);
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+ $ this ->conflicts = [];
156
+ }
157
+
139
158
$ data = [];
140
159
$ urls = [];
141
160
$ chunk = '' ;
@@ -210,6 +229,10 @@ public function getRecipes(array $operations): array
210
229
continue ;
211
230
}
212
231
232
+ if (\is_array ($ recipeVersions )) {
233
+ $ data ['conflicts ' ][$ package ->getName ()] = true ;
234
+ }
235
+
213
236
if (null !== $ this ->endpoints ) {
214
237
$ data ['locks ' ][$ package ->getName ()]['version ' ] = $ version ;
215
238
continue ;
@@ -434,11 +457,14 @@ private function initialize()
434
457
foreach ($ config ['recipes ' ] ?? [] as $ package => $ versions ) {
435
458
$ this ->index [$ package ] = $ this ->index [$ package ] ?? array_fill_keys ($ versions , $ endpoint );
436
459
}
460
+ $ this ->conflicts [] = $ config ['recipe-conflicts ' ] ?? [];
437
461
self ::$ versions += $ config ['versions ' ] ?? [];
438
462
self ::$ aliases += $ config ['aliases ' ] ?? [];
439
- unset($ config ['recipes ' ], $ config ['versions ' ], $ config ['aliases ' ]);
463
+ unset($ config ['recipes ' ], $ config ['recipe-conflicts ' ], $ config [ ' versions ' ], $ config ['aliases ' ]);
440
464
$ this ->endpoints [$ endpoint ] = $ config ;
441
465
}
466
+
467
+ return false ;
442
468
}
443
469
444
470
private static function generateCacheKey (string $ url ): string
0 commit comments