You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #865 Making conflict smarter: choose an older recipe to apply (weaverryan)
This PR was merged into the 1.x branch.
Discussion
----------
Making conflict smarter: choose an older recipe to apply
Hi!
Flex recipes support a `conflict` key - e.g. https://github.com/symfony/recipes/blob/ee79aec15811a380b09c53d058972c74e77e25d9/doctrine/doctrine-bundle/2.4/manifest.json#L48-L50
In this case, we added that so that we could use `when@dev` in the recipe, but that requires `symfony/framework-bundle` 5.3 or greater.
Anyways, the current `conflict` behavior is overly simple: if a recipe conflicts with a package you have installed, it simply skips the recipe entirely. This, for example, makes the following fail right now:
```
symfony new 4.4_app --version=4.4
cd 4.4_app
composer require doctrine
```
If you try this, the `doctrine/doctrine-bundle` will be skipped **entirely**.
This PR makes that behavior smarter. For each recipe that conflicts with your app (e.g. `doctrine/doctrine-bundle` 2.4 recipe), it will try the next oldest recipe version (e.g. `doctrine/doctrine-bundle` 2.3) until it finds one that does *not* conflict. So, you will always get the latest recipe version *without* any conflicts. If no compatible recipes are found, none would be installed (but I don't believe we have this situation anywhere anyways).
Tested locally on an app also.
Cheers!
Commits
-------
f921327 Making conflict smarter: choose an older recipe to apply
if ($lockedRepository->findPackage($conflictingPackage, $constraint)) {
733
-
$this->io->writeError(sprintf(' - Skipping recipe for %s: it conflicts with %s %s.', $name, $conflictingPackage, $constraint), true, IOInterface::VERBOSE);
734
+
if (!isset($newManifests[$name])) {
735
+
// no older recipe found
736
+
$this->io->writeError(sprintf(' - Skipping recipe for %s: all versions of the recipe conflict with your package versions.', $name), true, IOInterface::VERBOSE);
734
737
735
-
continue2;
736
-
}
738
+
continue2;
737
739
}
740
+
741
+
// push the "old" recipe into the $manifests
742
+
$manifests[$name] = $newManifests[$name];
743
+
$locks[$name] = $newData['locks'][$name];
738
744
}
739
745
740
746
if ($operationinstanceof InstallOperation && isset($locks[$name])) {
@@ -991,4 +997,21 @@ public static function getSubscribedEvents(): array
0 commit comments