Fix dependency flags not applying to provides/replaces, fixes #1771
parent
1f79f36227
commit
2b385cbe58
|
@ -90,9 +90,6 @@ 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(
|
||||
|
@ -108,8 +105,13 @@ class Pool
|
|||
$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,15 +323,17 @@ class Pool
|
|||
|
||||
public function isPackageAcceptable($name, $stability)
|
||||
{
|
||||
foreach ((array) $name as $n) {
|
||||
// allow if package matches the global stability requirement and has no exception
|
||||
if (!isset($this->stabilityFlags[$name]) && isset($this->acceptableStabilities[$stability])) {
|
||||
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]) {
|
||||
if (isset($this->stabilityFlags[$n]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$n]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue