From 4bd748b4630d01e3c268a941f748d0c317b7a156 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 19 Jul 2014 19:43:59 +0200 Subject: [PATCH] Fix BC issue from #3101 --- src/Composer/Installer.php | 12 +++++++++++- src/Composer/Package/Locker.php | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index eb4db08c4..0fb66553b 100644 --- a/src/Composer/Installer.php +++ b/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) diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index bee955288..ab5d432e0 100644 --- a/src/Composer/Package/Locker.php +++ b/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 */