From 903facd64fee3941c4abc3e945982395cfb166b4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 24 Apr 2012 11:16:25 +0200 Subject: [PATCH] Make sure the anti-aliased package contains the alias info from the correct alias --- .../Installer/InstallationManager.php | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index f2fd405c8..e5080e0ef 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -127,11 +127,7 @@ class InstallationManager */ public function install(RepositoryInterface $repo, InstallOperation $operation) { - $package = $operation->getPackage(); - if ($package instanceof AliasPackage) { - $package = $package->getAliasOf(); - $package->setInstalledAsAlias(true); - } + $package = $this->antiAlias($operation->getPackage()); $installer = $this->getInstaller($package->getType()); $installer->install($repo, $package); $this->notifyInstall($package); @@ -145,15 +141,8 @@ class InstallationManager */ public function update(RepositoryInterface $repo, UpdateOperation $operation) { - $initial = $operation->getInitialPackage(); - if ($initial instanceof AliasPackage) { - $initial = $initial->getAliasOf(); - } - $target = $operation->getTargetPackage(); - if ($target instanceof AliasPackage) { - $target = $target->getAliasOf(); - $target->setInstalledAsAlias(true); - } + $initial = $this->antiAlias($operation->getInitialPackage()); + $target = $this->antiAlias($operation->getTargetPackage()); $initialType = $initial->getType(); $targetType = $target->getType(); @@ -176,10 +165,7 @@ class InstallationManager */ public function uninstall(RepositoryInterface $repo, UninstallOperation $operation) { - $package = $operation->getPackage(); - if ($package instanceof AliasPackage) { - $package = $package->getAliasOf(); - } + $package = $this->antiAlias($operation->getPackage()); $installer = $this->getInstaller($package->getType()); $installer->uninstall($repo, $package); } @@ -217,4 +203,17 @@ class InstallationManager $package->getRepository()->notifyInstall($package); } } + + private function antiAlias(PackageInterface $package) + { + if ($package instanceof AliasPackage) { + $alias = $package; + $package = $package->getAliasOf(); + $package->setInstalledAsAlias(true); + $package->setAlias($alias->getVersion()); + $package->setPrettyAlias($alias->getPrettyVersion()); + } + + return $package; + } }