@@ -203,27 +203,38 @@ public function getRecipes(array $operations): array
203203 $ version = $ version [0 ].'. ' .($ version [1 ] ?? '9999999 ' );
204204
205205 foreach (array_reverse ($ recipeVersions ) as $ v => $ endpoint ) {
206- if (version_compare ($ version , $ v , '>= ' )) {
207- $ data [ ' locks ' ][ $ package -> getName ()][ ' version ' ] = $ version ;
208- $ data [ ' locks ' ][ $ package -> getName ()][ ' recipe ' ][ ' version ' ] = $ v ;
206+ if (version_compare ($ version , $ v , '< ' )) {
207+ continue ;
208+ }
209209
210- if (null !== $ recipeRef && isset ($ this ->endpoints [$ endpoint ]['_links ' ]['archived_recipes_template ' ])) {
211- $ urls [] = strtr ($ this ->endpoints [$ endpoint ]['_links ' ]['archived_recipes_template ' ], [
212- '{package_dotted} ' => str_replace ('/ ' , '. ' , $ package ->getName ()),
213- '{ref} ' => $ recipeRef ,
214- ]);
210+ $ data ['locks ' ][$ package ->getName ()]['version ' ] = $ version ;
211+ $ data ['locks ' ][$ package ->getName ()]['recipe ' ]['version ' ] = $ v ;
212+ $ links = $ this ->endpoints [$ endpoint ]['_links ' ];
215213
216- break ;
214+ if (null !== $ recipeRef && isset ($ links ['archived_recipes_template ' ])) {
215+ if (isset ($ links ['archived_recipes_template_relative ' ])) {
216+ $ links ['archived_recipes_template ' ] = preg_replace ('{[^/\?]*+(?=\?|$)} ' , $ links ['archived_recipes_template_relative ' ], $ endpoint , 1 );
217217 }
218218
219- $ urls [] = strtr ($ this -> endpoints [ $ endpoint ][ ' _links ' ][ ' recipe_template ' ], [
219+ $ urls [] = strtr ($ links [ ' archived_recipes_template ' ], [
220220 '{package_dotted} ' => str_replace ('/ ' , '. ' , $ package ->getName ()),
221- '{package} ' => $ package ->getName (),
222- '{version} ' => $ v ,
221+ '{ref} ' => $ recipeRef ,
223222 ]);
224223
225224 break ;
226225 }
226+
227+ if (isset ($ links ['recipes_template_relative ' ])) {
228+ $ links ['recipes_template ' ] = preg_replace ('{[^/\?]*+(?=\?|$)} ' , $ links ['recipes_template_relative ' ], $ endpoint , 1 );
229+ }
230+
231+ $ urls [] = strtr ($ links ['recipe_template ' ], [
232+ '{package_dotted} ' => str_replace ('/ ' , '. ' , $ package ->getName ()),
233+ '{package} ' => $ package ->getName (),
234+ '{version} ' => $ v ,
235+ ]);
236+
237+ break ;
227238 }
228239
229240 continue ;
0 commit comments