Browse Source

Fix BC issue from #3101

Jordi Boggiano 10 years ago
parent
commit
4bd748b463
2 changed files with 13 additions and 2 deletions
  1. 11 1
      src/Composer/Installer.php
  2. 2 1
      src/Composer/Package/Locker.php

+ 11 - 1
src/Composer/Installer.php

@@ -648,7 +648,17 @@ class Installer
 
     private function createPolicy()
     {
-        return new DefaultPolicy((!$this->update && $this->locker->isLocked()) ? $this->locker->getPreferStable() : $this->package->getPreferStable());
+        $preferStable = null;
+        if (!$this->update && $this->locker->isLocked()) {
+            $preferStable = $this->locker->getPreferStable();
+        }
+        // old lock file without prefer stable will return null
+        // so in this case we use the composer.json info
+        if (null === $preferStable) {
+            $preferStable = $this->package->getPreferStable();
+        }
+
+        return new DefaultPolicy($preferStable);
     }
 
     private function createRequest(Pool $pool, RootPackageInterface $rootPackage, PlatformRepository $platformRepo)

+ 2 - 1
src/Composer/Package/Locker.php

@@ -177,7 +177,7 @@ class Locker
     {
         $lockData = $this->getLockData();
 
-        return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : false;
+        return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
     }
 
     public function getAliases()
@@ -210,6 +210,7 @@ class Locker
      * @param array  $aliases          array of aliases
      * @param string $minimumStability
      * @param array  $stabilityFlags
+     * @param bool   $preferStable
      *
      * @return bool
      */