From f63df842b3febdb9dcc0a915254ae074b2a76636 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 15 Apr 2012 19:05:16 +0200 Subject: [PATCH] Fix alias handling with --dev installs, fixes #579 --- src/Composer/Installer.php | 25 +++++++++++-------- .../Repository/FilesystemRepository.php | 7 ++++++ .../WritableRepositoryInterface.php | 5 ++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 13a8479ac..eb6e0ee03 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -136,13 +136,6 @@ class Installer $aliases = $this->aliasPackages(); - // creating repository pool - $pool = new Pool; - $pool->addRepository($installedRepo); - foreach ($this->repositoryManager->getRepositories() as $repository) { - $pool->addRepository($repository); - } - if (!$this->dryRun) { // dispatch pre event $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD; @@ -150,11 +143,11 @@ class Installer } $this->suggestedPackages = array(); - if (!$this->doInstall($this->repositoryManager->getLocalRepository(), $installedRepo, $pool, $aliases)) { + if (!$this->doInstall($this->repositoryManager->getLocalRepository(), $installedRepo, $aliases)) { return false; } if ($this->devMode) { - if (!$this->doInstall($this->repositoryManager->getLocalDevRepository(), $installedRepo, $pool, $aliases, true)) { + if (!$this->doInstall($this->repositoryManager->getLocalDevRepository(), $installedRepo, $aliases, true)) { return false; } } @@ -191,8 +184,15 @@ class Installer return true; } - protected function doInstall($localRepo, $installedRepo, $pool, $aliases, $devMode = false) + protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false) { + // creating repository pool + $pool = new Pool; + $pool->addRepository($installedRepo); + foreach ($this->repositoryManager->getRepositories() as $repository) { + $pool->addRepository($repository); + } + // creating requirements request $installFromLock = false; $request = new Request($pool); @@ -358,6 +358,11 @@ class Installer } } + // reload local repository for the dev pass to work ok with aliases since it was anti-aliased above + if (!$devMode) { + $localRepo->reload(); + } + return true; } diff --git a/src/Composer/Repository/FilesystemRepository.php b/src/Composer/Repository/FilesystemRepository.php index 95cb11b4b..8bbeb6ad3 100644 --- a/src/Composer/Repository/FilesystemRepository.php +++ b/src/Composer/Repository/FilesystemRepository.php @@ -21,6 +21,7 @@ use Composer\Package\Dumper\ArrayDumper; * Filesystem repository. * * @author Konstantin Kudryashov + * @author Jordi Boggiano */ class FilesystemRepository extends ArrayRepository implements WritableRepositoryInterface { @@ -71,6 +72,12 @@ class FilesystemRepository extends ArrayRepository implements WritableRepository } } + public function reload() + { + $this->packages = null; + $this->initialize(); + } + /** * Writes writable repository. */ diff --git a/src/Composer/Repository/WritableRepositoryInterface.php b/src/Composer/Repository/WritableRepositoryInterface.php index 77291e889..dc67628ad 100644 --- a/src/Composer/Repository/WritableRepositoryInterface.php +++ b/src/Composer/Repository/WritableRepositoryInterface.php @@ -39,4 +39,9 @@ interface WritableRepositoryInterface extends RepositoryInterface * @param PackageInterface $package package instance */ function removePackage(PackageInterface $package); + + /** + * Forces a reload of all packages + */ + function reload(); }