From 3c0edd8c7fccacdbb04a6c9964944c4b843b3b81 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 7 Apr 2014 11:10:26 +0200 Subject: [PATCH] Process remove ops first, fixes #2874 --- src/Composer/Installer.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index ffbbbb9dd..03e6beb92 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -481,6 +481,7 @@ class Installer } $operations = $this->movePluginsToFront($operations); + $operations = $this->moveUninstallsToFront($operations); foreach ($operations as $operation) { // collect suggestions @@ -591,6 +592,26 @@ class Installer return array_merge($installerOps, $operations); } + /** + * Removals of packages should be executed before installations in + * case two packages resolve to the same path (due to custom installers) + * + * @param OperationInterface[] $operations + * @return OperationInterface[] reordered operation list + */ + private function moveUninstallsToFront(array $operations) + { + $uninstOps = array(); + foreach ($operations as $idx => $op) { + if ($op instanceof UninstallOperation) { + $uninstOps[] = $op; + unset($operations[$idx]); + } + } + + return array_merge($uninstOps, $operations); + } + private function createPool($withDevReqs) { $minimumStability = $this->package->getMinimumStability();