Skip to content

Commit

Permalink
Strengthening checks around Locker use.
Browse files Browse the repository at this point in the history
Hi Rob,

I just changed the way you check if the locker is available or not in the "init()" method.
At this point in the process, since we are in post-dump-autoload, we should be safe to assume that the lockfile is created. Therefore, the test as you wrote (`if (isset(($locker)) {...}`) should always be true.

However, in very special circumstances (like when you are using [EmbeddedComposer](https://github.com/dflydev/dflydev-embedded-composer), there can be really no lock file. The test is still true, but the call to `$locker->getLockData()` throws an exception (lock file not found). The piece of code I added actually checks that the lock file exists, and the test fails if the lock file does not exist (or if it contains no packages).
  • Loading branch information
moufmouf committed May 28, 2015
1 parent b9d69bd commit 716b95b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ComponentInstaller/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public function init()
$allPackages = array();
/** @var \Composer\Package\Locker $locker */
$locker = $this->composer->getLocker();
if (isset($locker)) {
if ($locker !== null && $locker->isLocked()) {
$lockData = $locker->getLockData();
$allPackages = isset($lockData['packages']) ? $lockData['packages'] : array();
$allPackages = $lockData['packages'];

// Also merge in any of the development packages.
$dev = isset($lockData['packages-dev']) ? $lockData['packages-dev'] : array();
Expand Down

0 comments on commit 716b95b

Please sign in to comment.