diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index 9e18b120e..fb5decf55 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -90,26 +90,28 @@ class Pool $name = $package['name']; $version = $package['version']; $stability = VersionParser::parseStability($version); - if ($exempt || $this->isPackageAcceptable($name, $stability)) { - $package['id'] = $this->id++; - $this->packages[] = $package; - // collect names - $names = array( - $name => true, - ); - if (isset($package['provide'])) { - foreach ($package['provide'] as $target => $constraint) { - $names[$target] = true; - } + // collect names + $names = array( + $name => true, + ); + if (isset($package['provide'])) { + foreach ($package['provide'] as $target => $constraint) { + $names[$target] = true; } - if (isset($package['replace'])) { - foreach ($package['replace'] as $target => $constraint) { - $names[$target] = true; - } + } + if (isset($package['replace'])) { + foreach ($package['replace'] as $target => $constraint) { + $names[$target] = true; } + } + $names = array_keys($names); - foreach (array_keys($names) as $provided) { + if ($exempt || $this->isPackageAcceptable($names, $stability)) { + $package['id'] = $this->id++; + $this->packages[] = $package; + + foreach ($names as $provided) { $this->packageByName[$provided][] =& $this->packages[$this->id - 2]; } @@ -131,7 +133,7 @@ class Pool $alias['root_alias'] = true; $this->packages[] = $alias; - foreach (array_keys($names) as $provided) { + foreach ($names as $provided) { $this->packageByName[$provided][] =& $this->packages[$this->id - 2]; } } @@ -146,7 +148,7 @@ class Pool $alias['id'] = $this->id++; $this->packages[] = $alias; - foreach (array_keys($names) as $provided) { + foreach ($names as $provided) { $this->packageByName[$provided][] =& $this->packages[$this->id - 2]; } } @@ -154,17 +156,18 @@ class Pool } } else { foreach ($repo->getPackages() as $package) { - $name = $package->getName(); + $names = $package->getNames(); $stability = $package->getStability(); - if ($exempt || $this->isPackageAcceptable($name, $stability)) { + if ($exempt || $this->isPackageAcceptable($names, $stability)) { $package->setId($this->id++); $this->packages[] = $package; - foreach ($package->getNames() as $provided) { + foreach ($names as $provided) { $this->packageByName[$provided][] = $package; } // handle root package aliases + $name = $package->getName(); if (isset($rootAliases[$name][$package->getVersion()])) { $alias = $rootAliases[$name][$package->getVersion()]; $package->setAlias($alias['alias_normalized']); @@ -320,14 +323,16 @@ class Pool public function isPackageAcceptable($name, $stability) { - // allow if package matches the global stability requirement and has no exception - if (!isset($this->stabilityFlags[$name]) && isset($this->acceptableStabilities[$stability])) { - return true; - } + foreach ((array) $name as $n) { + // allow if package matches the global stability requirement and has no exception + if (!isset($this->stabilityFlags[$n]) && isset($this->acceptableStabilities[$stability])) { + return true; + } - // allow if package matches the package-specific stability flag - if (isset($this->stabilityFlags[$name]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$name]) { - return true; + // allow if package matches the package-specific stability flag + if (isset($this->stabilityFlags[$n]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$n]) { + return true; + } } return false; diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 0c0d1404d..132958622 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -330,7 +330,7 @@ class Installer $removedUnstablePackages = array(); foreach ($localRepo->getPackages() as $package) { if ( - !$pool->isPackageAcceptable($package->getName(), $package->getStability()) + !$pool->isPackageAcceptable($package->getNames(), $package->getStability()) && $this->installationManager->isPackageInstalled($localRepo, $package) ) { $removedUnstablePackages[$package->getName()] = true; diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 711b8e43c..3959de41f 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -295,6 +295,25 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository } } } else { + if (isset($version['provide']) || isset($version['replace'])) { + // collect names + $names = array( + strtolower($version['name']) => true, + ); + if (isset($version['provide'])) { + foreach ($version['provide'] as $target => $constraint) { + $names[strtolower($target)] = true; + } + } + if (isset($version['replace'])) { + foreach ($version['replace'] as $target => $constraint) { + $names[strtolower($target)] = true; + } + } + $names = array_keys($names); + } else { + $names = array(strtolower($version['name'])); + } if (!$pool->isPackageAcceptable(strtolower($version['name']), VersionParser::parseStability($version['version']))) { continue; }