Merge pull request #8444 from Toflar/remove-filters-from-pool
Removed the filters from the poolpull/8528/head
commit
2bd817acf9
|
@ -32,20 +32,16 @@ class Pool implements \Countable
|
||||||
const MATCH = 1;
|
const MATCH = 1;
|
||||||
const MATCH_PROVIDE = 2;
|
const MATCH_PROVIDE = 2;
|
||||||
const MATCH_REPLACE = 3;
|
const MATCH_REPLACE = 3;
|
||||||
const MATCH_FILTERED = 4;
|
|
||||||
|
|
||||||
protected $providerRepos = array();
|
|
||||||
protected $packages = array();
|
protected $packages = array();
|
||||||
protected $packageByName = array();
|
protected $packageByName = array();
|
||||||
protected $packageByExactName = array();
|
protected $packageByExactName = array();
|
||||||
protected $priorities = array();
|
protected $priorities = array();
|
||||||
protected $versionParser;
|
protected $versionParser;
|
||||||
protected $providerCache = array();
|
protected $providerCache = array();
|
||||||
protected $filterRequires;
|
|
||||||
|
|
||||||
public function __construct(array $filterRequires = array())
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->filterRequires = $filterRequires;
|
|
||||||
$this->versionParser = new VersionParser;
|
$this->versionParser = new VersionParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,27 +95,22 @@ class Pool implements \Countable
|
||||||
* packages must match or null to return all
|
* packages must match or null to return all
|
||||||
* @param bool $mustMatchName Whether the name of returned packages
|
* @param bool $mustMatchName Whether the name of returned packages
|
||||||
* must match the given name
|
* must match the given name
|
||||||
* @param bool $bypassFilters If enabled, filterRequires and stability matching is ignored
|
|
||||||
* @return PackageInterface[] A set of packages
|
* @return PackageInterface[] A set of packages
|
||||||
*/
|
*/
|
||||||
public function whatProvides($name, ConstraintInterface $constraint = null, $mustMatchName = false, $bypassFilters = false)
|
public function whatProvides($name, ConstraintInterface $constraint = null, $mustMatchName = false)
|
||||||
{
|
{
|
||||||
if ($bypassFilters) {
|
|
||||||
return $this->computeWhatProvides($name, $constraint, $mustMatchName, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = ((int) $mustMatchName).$constraint;
|
$key = ((int) $mustMatchName).$constraint;
|
||||||
if (isset($this->providerCache[$name][$key])) {
|
if (isset($this->providerCache[$name][$key])) {
|
||||||
return $this->providerCache[$name][$key];
|
return $this->providerCache[$name][$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName, $bypassFilters);
|
return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see whatProvides
|
* @see whatProvides
|
||||||
*/
|
*/
|
||||||
private function computeWhatProvides($name, $constraint, $mustMatchName = false, $bypassFilters = false)
|
private function computeWhatProvides($name, $constraint, $mustMatchName = false)
|
||||||
{
|
{
|
||||||
$candidates = array();
|
$candidates = array();
|
||||||
|
|
||||||
|
@ -135,7 +126,7 @@ class Pool implements \Countable
|
||||||
$nameMatch = false;
|
$nameMatch = false;
|
||||||
|
|
||||||
foreach ($candidates as $candidate) {
|
foreach ($candidates as $candidate) {
|
||||||
switch ($this->match($candidate, $name, $constraint, $bypassFilters)) {
|
switch ($this->match($candidate, $name, $constraint)) {
|
||||||
case self::MATCH_NONE:
|
case self::MATCH_NONE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -156,9 +147,6 @@ class Pool implements \Countable
|
||||||
$matches[] = $candidate;
|
$matches[] = $candidate;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::MATCH_FILTERED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \UnexpectedValueException('Unexpected match type');
|
throw new \UnexpectedValueException('Unexpected match type');
|
||||||
}
|
}
|
||||||
|
@ -201,24 +189,16 @@ class Pool implements \Countable
|
||||||
* @param ConstraintInterface $constraint The constraint to verify
|
* @param ConstraintInterface $constraint The constraint to verify
|
||||||
* @return int One of the MATCH* constants of this class or 0 if there is no match
|
* @return int One of the MATCH* constants of this class or 0 if there is no match
|
||||||
*/
|
*/
|
||||||
public function match($candidate, $name, ConstraintInterface $constraint = null, $bypassFilters)
|
public function match($candidate, $name, ConstraintInterface $constraint = null)
|
||||||
{
|
{
|
||||||
$candidateName = $candidate->getName();
|
$candidateName = $candidate->getName();
|
||||||
$candidateVersion = $candidate->getVersion();
|
$candidateVersion = $candidate->getVersion();
|
||||||
$isDev = $candidate->getStability() === 'dev';
|
|
||||||
$isAlias = $candidate instanceof AliasPackage;
|
|
||||||
|
|
||||||
if (!$bypassFilters && !$isDev && !$isAlias && isset($this->filterRequires[$name])) {
|
|
||||||
$requireFilter = $this->filterRequires[$name];
|
|
||||||
} else {
|
|
||||||
$requireFilter = new EmptyConstraint;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($candidateName === $name) {
|
if ($candidateName === $name) {
|
||||||
$pkgConstraint = new Constraint('==', $candidateVersion);
|
$pkgConstraint = new Constraint('==', $candidateVersion);
|
||||||
|
|
||||||
if ($constraint === null || $constraint->matches($pkgConstraint)) {
|
if ($constraint === null || $constraint->matches($pkgConstraint)) {
|
||||||
return $requireFilter->matches($pkgConstraint) ? self::MATCH : self::MATCH_FILTERED;
|
return self::MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::MATCH_NAME;
|
return self::MATCH_NAME;
|
||||||
|
@ -231,13 +211,13 @@ class Pool implements \Countable
|
||||||
if (isset($replaces[0]) || isset($provides[0])) {
|
if (isset($replaces[0]) || isset($provides[0])) {
|
||||||
foreach ($provides as $link) {
|
foreach ($provides as $link) {
|
||||||
if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
|
if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
|
||||||
return $requireFilter->matches($link->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED;
|
return self::MATCH_PROVIDE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($replaces as $link) {
|
foreach ($replaces as $link) {
|
||||||
if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
|
if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
|
||||||
return $requireFilter->matches($link->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED;
|
return self::MATCH_REPLACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,11 +225,11 @@ class Pool implements \Countable
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
|
if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
|
||||||
return $requireFilter->matches($provides[$name]->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED;
|
return self::MATCH_PROVIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
|
if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
|
||||||
return $requireFilter->matches($replaces[$name]->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED;
|
return self::MATCH_REPLACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::MATCH_NONE;
|
return self::MATCH_NONE;
|
||||||
|
|
|
@ -28,7 +28,7 @@ use Composer\Semver\Constraint\MultiConstraint;
|
||||||
class PoolBuilder
|
class PoolBuilder
|
||||||
{
|
{
|
||||||
private $isPackageAcceptableCallable;
|
private $isPackageAcceptableCallable;
|
||||||
private $filterRequires;
|
private $rootRequires;
|
||||||
private $rootAliases;
|
private $rootAliases;
|
||||||
private $rootReferences;
|
private $rootReferences;
|
||||||
|
|
||||||
|
@ -40,15 +40,15 @@ class PoolBuilder
|
||||||
private $packages = array();
|
private $packages = array();
|
||||||
private $priorities = array();
|
private $priorities = array();
|
||||||
|
|
||||||
public function __construct($isPackageAcceptableCallable, array $filterRequires = array())
|
public function __construct($isPackageAcceptableCallable, array $rootRequires = array())
|
||||||
{
|
{
|
||||||
$this->isPackageAcceptableCallable = $isPackageAcceptableCallable;
|
$this->isPackageAcceptableCallable = $isPackageAcceptableCallable;
|
||||||
$this->filterRequires = $filterRequires;
|
$this->rootRequires = $rootRequires;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildPool(array $repositories, array $rootAliases, array $rootReferences, Request $request)
|
public function buildPool(array $repositories, array $rootAliases, array $rootReferences, Request $request)
|
||||||
{
|
{
|
||||||
$pool = new Pool($this->filterRequires);
|
$pool = new Pool();
|
||||||
$this->rootAliases = $rootAliases;
|
$this->rootAliases = $rootAliases;
|
||||||
$this->rootReferences = $rootReferences;
|
$this->rootReferences = $rootReferences;
|
||||||
|
|
||||||
|
|
|
@ -148,13 +148,15 @@ class Problem
|
||||||
return "\n - The requested package ".$packageName.' could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.';
|
return "\n - The requested package ".$packageName.' could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($providers = $this->pool->whatProvides($packageName, $constraint, true, true)) {
|
// TODO: The pool doesn't know about these anymore, it has to ask the RepositorySet
|
||||||
|
/*if ($providers = $this->pool->whatProvides($packageName, $constraint, true, true)) {
|
||||||
return "\n - The requested package ".$packageName.$this->constraintToText($constraint).' is satisfiable by '.$this->getPackageList($providers).' but these conflict with your requirements or minimum-stability.';
|
return "\n - The requested package ".$packageName.$this->constraintToText($constraint).' is satisfiable by '.$this->getPackageList($providers).' but these conflict with your requirements or minimum-stability.';
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ($providers = $this->pool->whatProvides($packageName, null, true, true)) {
|
// TODO: The pool doesn't know about these anymore, it has to ask the RepositorySet
|
||||||
|
/*if ($providers = $this->pool->whatProvides($packageName, null, true, true)) {
|
||||||
return "\n - The requested package ".$packageName.$this->constraintToText($constraint).' exists as '.$this->getPackageList($providers).' but these are rejected by your constraint.';
|
return "\n - The requested package ".$packageName.$this->constraintToText($constraint).' exists as '.$this->getPackageList($providers).' but these are rejected by your constraint.';
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return "\n - The requested package ".$packageName.' could not be found in any version, there may be a typo in the package name.';
|
return "\n - The requested package ".$packageName.' could not be found in any version, there may be a typo in the package name.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,9 +217,10 @@ abstract class Rule
|
||||||
return $text . ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
|
return $text . ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($providers = $pool->whatProvides($targetName, $this->reasonData->getConstraint(), true, true)) {
|
// TODO: The pool doesn't know about these anymore, it has to ask the RepositorySet
|
||||||
|
/*if ($providers = $pool->whatProvides($targetName, $this->reasonData->getConstraint(), true, true)) {
|
||||||
return $text . ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $providers) .' but these conflict with your requirements or minimum-stability.';
|
return $text . ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $providers) .' but these conflict with your requirements or minimum-stability.';
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return $text . ' -> no matching package found.';
|
return $text . ' -> no matching package found.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,16 +717,16 @@ class Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootConstraints = array();
|
$rootRequires = array();
|
||||||
foreach ($requires as $req => $constraint) {
|
foreach ($requires as $req => $constraint) {
|
||||||
// skip platform requirements from the root package to avoid filtering out existing platform packages
|
// skip platform requirements from the root package to avoid filtering out existing platform packages
|
||||||
if ($this->ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
|
if ($this->ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($constraint instanceof Link) {
|
if ($constraint instanceof Link) {
|
||||||
$rootConstraints[$req] = $constraint->getConstraint();
|
$rootRequires[$req] = $constraint->getConstraint();
|
||||||
} else {
|
} else {
|
||||||
$rootConstraints[$req] = $constraint;
|
$rootRequires[$req] = $constraint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,7 +734,7 @@ class Installer
|
||||||
$this->fixedRootPackage->setRequires(array());
|
$this->fixedRootPackage->setRequires(array());
|
||||||
$this->fixedRootPackage->setDevRequires(array());
|
$this->fixedRootPackage->setDevRequires(array());
|
||||||
|
|
||||||
$repositorySet = new RepositorySet($rootAliases, $this->package->getReferences(), $minimumStability, $stabilityFlags, $rootConstraints);
|
$repositorySet = new RepositorySet($rootAliases, $this->package->getReferences(), $minimumStability, $stabilityFlags, $rootRequires);
|
||||||
$repositorySet->addRepository(new InstalledArrayRepository(array($this->fixedRootPackage)));
|
$repositorySet->addRepository(new InstalledArrayRepository(array($this->fixedRootPackage)));
|
||||||
$repositorySet->addRepository($platformRepo);
|
$repositorySet->addRepository($platformRepo);
|
||||||
if ($this->additionalFixedRepository) {
|
if ($this->additionalFixedRepository) {
|
||||||
|
|
|
@ -37,12 +37,12 @@ class RepositorySet
|
||||||
|
|
||||||
private $acceptableStabilities;
|
private $acceptableStabilities;
|
||||||
private $stabilityFlags;
|
private $stabilityFlags;
|
||||||
protected $filterRequires;
|
protected $rootRequires;
|
||||||
|
|
||||||
/** @var Pool */
|
/** @var Pool */
|
||||||
private $pool;
|
private $pool;
|
||||||
|
|
||||||
public function __construct(array $rootAliases = array(), array $rootReferences = array(), $minimumStability = 'stable', array $stabilityFlags = array(), array $filterRequires = array())
|
public function __construct(array $rootAliases = array(), array $rootReferences = array(), $minimumStability = 'stable', array $stabilityFlags = array(), array $rootRequires = array())
|
||||||
{
|
{
|
||||||
$this->rootAliases = $rootAliases;
|
$this->rootAliases = $rootAliases;
|
||||||
$this->rootReferences = $rootReferences;
|
$this->rootReferences = $rootReferences;
|
||||||
|
@ -54,10 +54,10 @@ class RepositorySet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->stabilityFlags = $stabilityFlags;
|
$this->stabilityFlags = $stabilityFlags;
|
||||||
$this->filterRequires = $filterRequires;
|
$this->rootRequires = $rootRequires;
|
||||||
foreach ($filterRequires as $name => $constraint) {
|
foreach ($rootRequires as $name => $constraint) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) {
|
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) {
|
||||||
unset($this->filterRequires[$name]);
|
unset($this->rootRequires[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ class RepositorySet
|
||||||
*/
|
*/
|
||||||
public function createPool(Request $request)
|
public function createPool(Request $request)
|
||||||
{
|
{
|
||||||
$poolBuilder = new PoolBuilder(array($this, 'isPackageAcceptable'), $this->filterRequires);
|
$poolBuilder = new PoolBuilder(array($this, 'isPackageAcceptable'), $this->rootRequires);
|
||||||
|
|
||||||
return $this->pool = $poolBuilder->buildPool($this->repositories, $this->rootAliases, $this->rootReferences, $request);
|
return $this->pool = $poolBuilder->buildPool($this->repositories, $this->rootAliases, $this->rootReferences, $request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,6 @@ class PoolTest extends TestCase
|
||||||
|
|
||||||
protected function createPool()
|
protected function createPool()
|
||||||
{
|
{
|
||||||
return new Pool(array('stable' => BasePackage::STABILITY_STABLE));
|
return new Pool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class RuleSetIteratorTest extends TestCase
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->pool = new Pool(array('stable' => BasePackage::STABILITY_STABLE));
|
$this->pool = new Pool();
|
||||||
|
|
||||||
$this->rules = array(
|
$this->rules = array(
|
||||||
RuleSet::TYPE_JOB => array(
|
RuleSet::TYPE_JOB => array(
|
||||||
|
|
|
@ -139,7 +139,7 @@ class RuleSetTest extends TestCase
|
||||||
|
|
||||||
public function testPrettyString()
|
public function testPrettyString()
|
||||||
{
|
{
|
||||||
$pool = new Pool(array('stable' => BasePackage::STABILITY_STABLE));
|
$pool = new Pool();
|
||||||
$pool->setPackages(array(
|
$pool->setPackages(array(
|
||||||
$p = $this->getPackage('foo', '2.1'),
|
$p = $this->getPackage('foo', '2.1'),
|
||||||
));
|
));
|
||||||
|
|
|
@ -93,7 +93,7 @@ class RuleTest extends TestCase
|
||||||
|
|
||||||
public function testPrettyString()
|
public function testPrettyString()
|
||||||
{
|
{
|
||||||
$pool = new Pool(array('stable' => BasePackage::STABILITY_STABLE));
|
$pool = new Pool();
|
||||||
$pool->setPackages(array(
|
$pool->setPackages(array(
|
||||||
$p1 = $this->getPackage('foo', '2.1'),
|
$p1 = $this->getPackage('foo', '2.1'),
|
||||||
$p2 = $this->getPackage('baz', '1.1'),
|
$p2 = $this->getPackage('baz', '1.1'),
|
||||||
|
|
|
@ -65,7 +65,7 @@ Your requirements could not be resolved to an installable set of packages.
|
||||||
- requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> no matching package found.
|
- requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> no matching package found.
|
||||||
Problem 4
|
Problem 4
|
||||||
- stable-requiree-excluded/pkg is locked to version 1.0.0 and an update of this package was not requested.
|
- stable-requiree-excluded/pkg is locked to version 1.0.0 and an update of this package was not requested.
|
||||||
- Same name, can only install one of: stable-requiree-excluded/pkg[1.0.1, 1.0.0].
|
- Same name, can only install one of: stable-requiree-excluded/pkg[1.0.0, 1.0.1].
|
||||||
- Installation request for stable-requiree-excluded/pkg 1.0.1 -> satisfiable by stable-requiree-excluded/pkg[1.0.1].
|
- Installation request for stable-requiree-excluded/pkg 1.0.1 -> satisfiable by stable-requiree-excluded/pkg[1.0.1].
|
||||||
|
|
||||||
Potential causes:
|
Potential causes:
|
||||||
|
|
Loading…
Reference in New Issue