Forráskód Böngészése

Process remove ops first, fixes #2874

Jordi Boggiano 11 éve
szülő
commit
3c0edd8c7f
1 módosított fájl, 21 hozzáadás és 0 törlés
  1. 21 0
      src/Composer/Installer.php

+ 21 - 0
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();