Fix various dumb issues
parent
aafc1f7857
commit
a3f9accd37
|
@ -219,7 +219,7 @@ class Pool
|
||||||
$candidates = array();
|
$candidates = array();
|
||||||
|
|
||||||
foreach ($this->composerRepos as $repo) {
|
foreach ($this->composerRepos as $repo) {
|
||||||
foreach ($repo->whatProvides($name) as $candidate) {
|
foreach ($repo->whatProvides($this, $name) as $candidate) {
|
||||||
$candidates[] = $candidate;
|
$candidates[] = $candidate;
|
||||||
if ($candidate->getId() < 1) {
|
if ($candidate->getId() < 1) {
|
||||||
$candidate->setId($this->id++);
|
$candidate->setId($this->id++);
|
||||||
|
@ -307,7 +307,7 @@ class Pool
|
||||||
return $prefix.' '.$package->getPrettyString();
|
return $prefix.' '.$package->getPrettyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isPackageAcceptable($name, $stability)
|
public function isPackageAcceptable($name, $stability)
|
||||||
{
|
{
|
||||||
// allow if package matches the global stability requirement and has no exception
|
// 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[$name]) && isset($this->acceptableStabilities[$stability])) {
|
||||||
|
|
|
@ -14,7 +14,9 @@ namespace Composer\Repository;
|
||||||
|
|
||||||
use Composer\Package\Loader\ArrayLoader;
|
use Composer\Package\Loader\ArrayLoader;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
|
use Composer\Package\AliasPackage;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
|
use Composer\DependencyResolver\Pool;
|
||||||
use Composer\Json\JsonFile;
|
use Composer\Json\JsonFile;
|
||||||
use Composer\Cache;
|
use Composer\Cache;
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
|
@ -194,7 +196,7 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
||||||
return null !== $this->providersUrl;
|
return null !== $this->providersUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function whatProvides($name)
|
public function whatProvides(Pool $pool, $name)
|
||||||
{
|
{
|
||||||
if ($name === 'php' || in_array(substr($name, 0, 4), array('ext-', 'lib-'), true) || $name === '__root__') {
|
if ($name === 'php' || in_array(substr($name, 0, 4), array('ext-', 'lib-'), true) || $name === '__root__') {
|
||||||
return array();
|
return array();
|
||||||
|
@ -216,22 +218,38 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->providers[$name] = array();
|
$this->providers[$name] = array();
|
||||||
foreach ($packages['packages'] as $name => $versions) {
|
foreach ($packages['packages'] as $versions) {
|
||||||
foreach ($versions as $version) {
|
foreach ($versions as $version) {
|
||||||
|
// avoid loading the same objects twice
|
||||||
if (isset($this->providersByUid[$version['uid']])) {
|
if (isset($this->providersByUid[$version['uid']])) {
|
||||||
$this->providers[$name][] = $this->providersByUid[$version['uid']];
|
// skip if already assigned
|
||||||
|
if (!isset($this->providers[$name][$version['uid']])) {
|
||||||
|
// expand alias in two packages
|
||||||
|
if ($this->providersByUid[$version['uid']] instanceof AliasPackage) {
|
||||||
|
$this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']]->getAliasOf();
|
||||||
|
$this->providers[$name][$version['uid'].'-alias'] = $this->providersByUid[$version['uid']];
|
||||||
} else {
|
} else {
|
||||||
|
$this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!$pool->isPackageAcceptable($version['name'], VersionParser::parseStability($version['version']))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// load acceptable packages in the providers
|
||||||
$package = $this->createPackage($version, 'Composer\Package\Package');
|
$package = $this->createPackage($version, 'Composer\Package\Package');
|
||||||
$package->setRepository($this);
|
$package->setRepository($this);
|
||||||
|
|
||||||
$this->providers[$name][] = $package;
|
$this->providers[$name][$version['uid']] = $package;
|
||||||
$this->providersByUid[$version['uid']] = $package;
|
$this->providersByUid[$version['uid']] = $package;
|
||||||
|
|
||||||
if ($package->getAlias()) {
|
if ($package->getAlias()) {
|
||||||
$alias = $this->createAliasPackage($package);
|
$alias = $this->createAliasPackage($package);
|
||||||
$alias->setRepository($this);
|
$alias->setRepository($this);
|
||||||
|
|
||||||
$this->providers[$name][] = $alias;
|
$this->providers[$name][$version['uid'].'-alias'] = $alias;
|
||||||
|
// override provider with its alias so it can be expanded in the if block above
|
||||||
$this->providersByUid[$version['uid']] = $alias;
|
$this->providersByUid[$version['uid']] = $alias;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue