Browse Source

Fix exception when solver could not resolve a set of packages

Jordi Boggiano 13 years ago
parent
commit
f520ce6a80
1 changed files with 15 additions and 7 deletions
  1. 15 7
      src/Composer/Installer.php

+ 15 - 7
src/Composer/Installer.php

@@ -82,6 +82,11 @@ class Installer
     protected $verbose = false;
     protected $update = false;
 
+    /**
+     * @var array
+     */
+    protected $suggestedPackages;
+
     /**
      * @var RepositoryInterface
      */
@@ -144,14 +149,18 @@ class Installer
             $this->eventDispatcher->dispatchCommandEvent($eventName);
         }
 
-        $suggestedPackages = $this->doInstall($this->repositoryManager->getLocalRepository(), $installedRepo, $pool, $aliases);
+        $this->suggestedPackages = array();
+        if (!$this->doInstall($this->repositoryManager->getLocalRepository(), $installedRepo, $pool, $aliases)) {
+            return false;
+        }
         if ($this->devMode) {
-            $devSuggested = $this->doInstall($this->repositoryManager->getLocalDevRepository(), $installedRepo, $pool, $aliases, true);
-            $suggestedPackages = array_merge($suggestedPackages, $devSuggested);
+            if (!$this->doInstall($this->repositoryManager->getLocalDevRepository(), $installedRepo, $pool, $aliases, true)) {
+                return false;
+            }
         }
 
         // dump suggestions
-        foreach ($suggestedPackages as $suggestion) {
+        foreach ($this->suggestedPackages as $suggestion) {
             $this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
         }
 
@@ -304,7 +313,6 @@ class Installer
             $this->io->write('Nothing to install or update');
         }
 
-        $suggestedPackages = array();
         foreach ($operations as $operation) {
             if ($this->verbose) {
                 $this->io->write((string) $operation);
@@ -313,7 +321,7 @@ class Installer
             // collect suggestions
             if ('install' === $operation->getJobType()) {
                 foreach ($operation->getPackage()->getSuggests() as $target => $reason) {
-                    $suggestedPackages[] = array(
+                    $this->suggestedPackages[] = array(
                         'source' => $operation->getPackage()->getPrettyName(),
                         'target' => $target,
                         'reason' => $reason,
@@ -350,7 +358,7 @@ class Installer
             }
         }
 
-        return $suggestedPackages;
+        return true;
     }
 
     private function aliasPackages()