Fix dependency flags not applying to provides/replaces, fixes #1771

main
Jordi Boggiano 11 years ago
parent 1f79f36227
commit 2b385cbe58

@ -90,26 +90,28 @@ class Pool
$name = $package['name']; $name = $package['name'];
$version = $package['version']; $version = $package['version'];
$stability = VersionParser::parseStability($version); $stability = VersionParser::parseStability($version);
if ($exempt || $this->isPackageAcceptable($name, $stability)) {
$package['id'] = $this->id++;
$this->packages[] = $package;
// collect names // collect names
$names = array( $names = array(
$name => true, $name => true,
); );
if (isset($package['provide'])) { if (isset($package['provide'])) {
foreach ($package['provide'] as $target => $constraint) { foreach ($package['provide'] as $target => $constraint) {
$names[$target] = true; $names[$target] = true;
}
} }
if (isset($package['replace'])) { }
foreach ($package['replace'] as $target => $constraint) { if (isset($package['replace'])) {
$names[$target] = true; 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]; $this->packageByName[$provided][] =& $this->packages[$this->id - 2];
} }
@ -131,7 +133,7 @@ class Pool
$alias['root_alias'] = true; $alias['root_alias'] = true;
$this->packages[] = $alias; $this->packages[] = $alias;
foreach (array_keys($names) as $provided) { foreach ($names as $provided) {
$this->packageByName[$provided][] =& $this->packages[$this->id - 2]; $this->packageByName[$provided][] =& $this->packages[$this->id - 2];
} }
} }
@ -146,7 +148,7 @@ class Pool
$alias['id'] = $this->id++; $alias['id'] = $this->id++;
$this->packages[] = $alias; $this->packages[] = $alias;
foreach (array_keys($names) as $provided) { foreach ($names as $provided) {
$this->packageByName[$provided][] =& $this->packages[$this->id - 2]; $this->packageByName[$provided][] =& $this->packages[$this->id - 2];
} }
} }
@ -154,17 +156,18 @@ class Pool
} }
} else { } else {
foreach ($repo->getPackages() as $package) { foreach ($repo->getPackages() as $package) {
$name = $package->getName(); $names = $package->getNames();
$stability = $package->getStability(); $stability = $package->getStability();
if ($exempt || $this->isPackageAcceptable($name, $stability)) { if ($exempt || $this->isPackageAcceptable($names, $stability)) {
$package->setId($this->id++); $package->setId($this->id++);
$this->packages[] = $package; $this->packages[] = $package;
foreach ($package->getNames() as $provided) { foreach ($names as $provided) {
$this->packageByName[$provided][] = $package; $this->packageByName[$provided][] = $package;
} }
// handle root package aliases // handle root package aliases
$name = $package->getName();
if (isset($rootAliases[$name][$package->getVersion()])) { if (isset($rootAliases[$name][$package->getVersion()])) {
$alias = $rootAliases[$name][$package->getVersion()]; $alias = $rootAliases[$name][$package->getVersion()];
$package->setAlias($alias['alias_normalized']); $package->setAlias($alias['alias_normalized']);
@ -320,14 +323,16 @@ class Pool
public function isPackageAcceptable($name, $stability) public function isPackageAcceptable($name, $stability)
{ {
// allow if package matches the global stability requirement and has no exception foreach ((array) $name as $n) {
if (!isset($this->stabilityFlags[$name]) && isset($this->acceptableStabilities[$stability])) { // allow if package matches the global stability requirement and has no exception
return true; if (!isset($this->stabilityFlags[$n]) && isset($this->acceptableStabilities[$stability])) {
} return true;
}
// allow if package matches the package-specific stability flag // allow if package matches the package-specific stability flag
if (isset($this->stabilityFlags[$name]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$name]) { if (isset($this->stabilityFlags[$n]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$n]) {
return true; return true;
}
} }
return false; return false;

@ -330,7 +330,7 @@ class Installer
$removedUnstablePackages = array(); $removedUnstablePackages = array();
foreach ($localRepo->getPackages() as $package) { foreach ($localRepo->getPackages() as $package) {
if ( if (
!$pool->isPackageAcceptable($package->getName(), $package->getStability()) !$pool->isPackageAcceptable($package->getNames(), $package->getStability())
&& $this->installationManager->isPackageInstalled($localRepo, $package) && $this->installationManager->isPackageInstalled($localRepo, $package)
) { ) {
$removedUnstablePackages[$package->getName()] = true; $removedUnstablePackages[$package->getName()] = true;

@ -295,6 +295,25 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
} }
} }
} else { } 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']))) { if (!$pool->isPackageAcceptable(strtolower($version['name']), VersionParser::parseStability($version['version']))) {
continue; continue;
} }

Loading…
Cancel
Save