From faeb706de6fbcd3e75f2ddcd2b14af97eccd5d9b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 May 2014 19:10:55 +0200 Subject: [PATCH] Handle alias packages properly, refs #2189 --- src/Composer/Package/AliasPackage.php | 8 ++++++++ src/Composer/Repository/ComposerRepository.php | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Composer/Package/AliasPackage.php b/src/Composer/Package/AliasPackage.php index 631b035a7..c90221027 100644 --- a/src/Composer/Package/AliasPackage.php +++ b/src/Composer/Package/AliasPackage.php @@ -233,6 +233,14 @@ class AliasPackage extends BasePackage implements CompletePackageInterface { return $this->aliasOf->getDistSha1Checksum(); } + public function setTransportOptions(array $options) + { + return $this->aliasOf->setTransportOptions($options); + } + public function getTransportOptions() + { + return $this->aliasOf->getTransportOptions(); + } public function getScripts() { return $this->aliasOf->getScripts(); diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 63b3dbf86..8ed6897c4 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -210,16 +210,15 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository $package = $package->getAliasOf(); } $package->setRepository($this); - $this->configurePackageOptions($package); return $package; } - protected function configurePackageOptions(PackageInterface $package) + protected function configurePackageTransportOptions(PackageInterface $package) { - if ($package instanceof Package - && strpos($package->getDistUrl(), $this->baseUrl) === 0) { + if (strpos($package->getDistUrl(), $this->baseUrl) === 0) { $package->setTransportOptions($this->options); + return; } } @@ -399,7 +398,7 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository public function addPackage(PackageInterface $package) { parent::addPackage($package); - $this->configurePackageOptions($package); + $this->configurePackageTransportOptions($package); } protected function loadRootServerFile() @@ -548,7 +547,10 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository $data['notification-url'] = $this->notifyUrl; } - return $this->loader->load($data, 'Composer\Package\CompletePackage'); + $package = $this->loader->load($data, 'Composer\Package\CompletePackage'); + $this->configurePackageTransportOptions($package); + + return $package; } catch (\Exception $e) { throw new \RuntimeException('Could not load package '.(isset($data['name']) ? $data['name'] : json_encode($data)).' in '.$this->url.': ['.get_class($e).'] '.$e->getMessage(), 0, $e); }