1
0
Fork 0
Commit Graph

212 Commits (456096d5fff9cb6b01591e80a481831e7a536c84)

Author SHA1 Message Date
Jordi Boggiano 3fc7e10c5c
Improve error reporting of solver issues, refs #7779
Fixes #8525
Fixes #6513
2020-01-30 14:43:54 +01:00
Nils Adermann 0b4e8952f6 PHP5 disallows require as a function name, use requireName analog to fixPackage 2020-01-19 23:28:00 +01:00
Nils Adermann 5bdc0fc9c5 Request jobs replaced by root require / fixed package
The only type of request job remaining was "install" which is really a
root requirement. The only other kind of input for the solver is now a
set of fixed packages.

Rules have been updated to account for only two kinds of former job
reason: FIXED or ROOT_REQUIRE. The job property has always been
redundant and has been removed, since reasonData suffices.

Problem reasons are always rules, so the unnecessary wrapping in an
array has been removed.

We now only ever generate a single rule per root require or fixed
package, so there is no need for the solver to special handle disabling
"jobs" anymore, the rule can just be disabled as usual.

For consistency special handling of rules for jobs in problems has been
integrated into the rule class like all other rule reasons. As part of
this change the error message for root requirements has been improved a
bit to make it clearer where the package installation request came from.

The word job has also been removed from operations, which are called
operations, not jobs.
2020-01-19 23:21:07 +01:00
Jordi Boggiano 921a97457d
Add PoolBuilder test harness for writing .test files 2020-01-19 19:46:16 +01:00
Jordi Boggiano 1d31190472
Keep track of unacceptable fixed packages for later to use in error reporting and make sure the pool state is consistent 2020-01-17 15:48:31 +01:00
Jordi Boggiano b5e34ca767
Fix remove tests 2020-01-17 14:57:33 +01:00
Jordi Boggiano 7a4d3e6f25
Fix SolverTest 2020-01-15 15:03:11 +01:00
Jordi Boggiano dd556f989b
Use LockArrayRepository instead of RepositoryInterface to clearly indicate which type of repo it is in some places 2020-01-15 14:56:58 +01:00
Jordi Boggiano f68731e663
Remove package/repo priority concept as it is enforced by the pool builder now 2020-01-15 14:52:44 +01:00
Yanick Witschi 02b6dc876f Fixed phpstan issues 2019-11-27 17:57:24 +01:00
Nils Adermann aa6bc75af2 Add a test case for transactions to verify correct sorting 2019-11-08 17:51:18 +01:00
Nils Adermann 25de5218c3 Reunify lock and local repo transaction code and apply the same sorting 2019-11-08 15:56:46 +01:00
Nils Adermann 26da52227e Clean up the Solver tests, no more installed repo input and new sorting
The solver now only calculates a lock file transaction which does not
need to be sorted in order of dependencies. This is only necessary for
the local repo transaction generated without the solver during install
2019-11-07 21:51:53 +01:00
Nils Adermann f5e18250e6 Merge remote-tracking branch 'github-composer/2.0' into solve-without-installed
* github-composer/2.0: (48 commits)
  Fix missing use/undefined var
  Split up steps on VCS downloaders to allow doing network operations before touching the filesystem on GitDownloader, fixes #7903
  Fix use statement
  Deduplicate findHeaderValue code
  Add install-path to the installed.json for every package, fixes #2174, closes #2424
  Remove unnecessary config from phpstan
  Make sure the directory exists and will not block installation later when downloading
  Avoid wiping the whole target package if download of the new one fails, refs #7929
  Only empty dir before actually installing packages, fixes #7929
  Improve output when installing packages
  Show best possible version in diagnose command
  Remove extra arg
  Allow path repos to point to their own source dir as install target, resulting in noop, fixes #8254
  Fix use of decodeJson
  Fix update mirrors to also update transport-options, fixes #7672
  Fix updating or URLs to include dist type and shasum, fixes #8216
  Fix origin computation
  Improve handling of non-standard ports for GitLab and GitHub installs, fixes #8173
  Load packages from the lock file for check-platform-reqs if no dependencies have been installed yet, fixes #8058
  Fix error_handler return type declaration
  ...
2019-09-07 02:55:21 +02:00
Nils Adermann f1e4ccbe1d Fix handling of reference updates and root references 2019-09-07 01:58:12 +02:00
Jordi Boggiano 6c4357a7ed
Merge branch 'master' into 2.0 2019-07-31 17:50:01 +02:00
Gabriel Caruso 1d05d4171c
Remove unused private methods 2019-07-24 03:13:53 +02:00
Nils Adermann 9053d74282 Merge branch '2.0' into solve-without-installed
* 2.0: (101 commits)
  SVN: hide passwords for debug output
  Free $solver asap
  fixes #8179
  [minor] Fixed a typo in the CHANGELOG.md.
  Update deps
  Update changelog
  Revert "Allow overriding self-update target file with envvar COMPOSER_SELF_UPDATE_TARGET" Revert "Add docs for COMPOSER_SELF_UPDATE_TARGET, refs #8151"
  Add docs for COMPOSER_SELF_UPDATE_TARGET, refs #8151
  Fix display of HHVM warning appearing when HHVM is not in use, fixes #8138
  Read classmap-authoritative and apcu-autoloader from project config when installing via create-project, fixes #8155
  Use possessive quantifiers
  Update xdebug-handler to 1.3.3
  fixes #8159
  Allow overriding self-update target file with envvar COMPOSER_SELF_UPDATE_TARGET
  flag should come before script name
  use full command name, not abbreviated/alias
  modify text
  Document the alternatives to disable the default script timeout
  Anchor pattern
  Fix URL resolution for Composer repositories
  ...
2019-06-27 14:35:36 +02:00
Jordi Boggiano 799717f102
Tweak and fix some more phpstan reports 2019-02-18 13:05:14 +01:00
Jordi Boggiano fb3d0981c0
Fix test suite 2019-02-18 12:35:24 +01:00
Nils Adermann 10ada7bf82 Refactor Installer class into separate install and update processes
- Introduce separate Lock and LocalRepo transactions, one for changes
  to the lock file, one for changes to locally installed packages based
  on lock file
- Remove various hacks to keep dev dependencies updated and
  incorporated the functionality into the transaction classes
- Remove installed repo, there are now local repo, locked repo and
  platform repo
- Remove access to local repo from solver, only supply locked packages
- Update can now be run to modify the lock file but not install packages
  to local repo
2019-02-11 01:00:02 +01:00
Nils Adermann 287419f6a0 Merge branch 'master' into 2.0
* master:
  Follow up to #7946 test: add solver flag to assert path execution
  Fix tests
  Make sure config command output is also output on --quiet so that warnings can be hidden, fixes #7963
  Recognize composer-plugin-api as a platform package, fixes #7951
  Quote wildcards to avoid issues in some shells, fixes #7960
  Avoid dumping null values for dist reference/shasum and source reference, fixes #7955
  Soften hard exit after revert of composer file
  Make unixy proxy code POSIX compatible
  Update aliases.md
  Same but for Problem.php
  Better error message for present but incompatible versions
  Fix inconsistent casing
  Don't do (new Foo())->bar() - not 5.3-compatible
  Support identifying the HHVM version when not running with HHVM
2019-02-10 20:28:24 +01:00
Nils Adermann 29ff6a40ae Follow up to #7946 test: add solver flag to assert path execution 2019-02-10 20:26:47 +01:00
Nils Adermann 728e57b9e0 Merge branch 'master' into 2.0
* master:
  Fix solver problem exceptions with unexpected contradictory "Conclusions"
  Also load config into IO if not freshly created
  Only load configuration into IO if IO is available
  Fix defaultRepos fallback does not use auth config
  Add warning/info msg when tweaking disable-tls setting to avoid confusion, fixes #7935
2019-02-05 15:35:51 +01:00
Nils Adermann 6b2edeae56 Fix solver problem exceptions with unexpected contradictory "Conclusions"
This 5 character fix comes with a solver test as well as a functional
installer test essentially verifying the same thing. The solver test is
more useful when working on the solver. But the functional test is less
likely to be accidentally modified incorrectly during refactoring, as
every single package, version and link in the rather complex test
scenario is essential, and a modified version of the test may very well
still result in a successful installation but no longer verify the bug
described below.

Background:

In commit 451bab1c2c from May 19, 2012 I
refactored literals from complex objects into pure integers to reduce
memory consumption. The absolute value of an integer literal is the id
of the package it refers to in the package pool. The sign indicates
whether the package should be installed (positive) or removed (negative),

So a major part of the refactoring was swapping this call:

$literal->getPackageId()

For this:

abs($literal)

Unintentionally in line 554/523 I incorrectly applied this change to the
line:

$this->literalFromId(-$literal->getPackageId());

It was converted to:

-abs($literal);

The function literalFromId used to create a new literal object. By using
the abs() function this change essentially forces the resulting literal
to be negative, while the minus sign previously inverted the literal, so
positive into negative and vice versa.

This particular line is in a function meant to analyze a conflicting
decision during dependency resolution and to draw a conclusion from it,
then revert the state of the solver to an earlier position, and attempt
to solve the rest of the rules again with this new "learned" conclusion.

Because of this bug these conclusions could only ever occur in the
negative, e.g. "don't install package X". This is by far the most likely
scenario when the solver reaches this particular line, but there are
exceptions.

If you experienced a solver problem description that contained a
statement like "Conclusion: don't install vendor/package 1.2.3" which
directly contradicted other statements listed as part of the problem,
this could likely have been the cause.
2019-02-03 16:33:55 +01:00
Jordi Boggiano 2e0f31106a Merge remote-tracking branch 'origin/master' into 2.0 2018-11-12 16:01:07 +01:00
Gabriel Caruso 2a13bb2649 Fixes from PHPStan (#7687)
* fix docblocks

* remove redundant conditional

* fix wrong variable name

* fix wrong namespaces

* add missing private members

* remove unused/redundant arguments

* move testcase class

* exclude TestCase.php

* Tweak RuleWatchGraph type hints

* Tweak doc comment
2018-11-12 15:23:32 +01:00
Nils Adermann 81bb8f81ad Set all package ids only once the pool is created
They all get set in one place only and at a specific time when nothing
else will possibly change them anymore
2018-09-12 14:31:40 +02:00
Nils Adermann c0f19f6c57 Move construction of pool from repo set into a pool builder
Pool construction depends on the install request now, so only required
packages get loaded, add some structure for future asynchronously
loading composer repositories
2018-09-12 11:49:09 +02:00
Nils Adermann b6e2d60c9e Create the pool in the installer before giving it to the solver 2018-09-11 15:49:08 +02:00
Nils Adermann 1228bcdffc Internalize pool creation in repository set, store root aliases in set
The pool is still exposed too early in a few places which will require
further refactoring
2018-09-11 13:34:18 +02:00
Nils Adermann 6ef65e5319 Add a new RepositorySet class and restrict pool usage to the solver
Breaking change for the plugin interface so bumping the version of
composer-plugin-api to 2.0.0

First step for a refactoring of the package metadata loading mechanism
2018-09-10 15:27:54 +02:00
Jordi Boggiano ff59bbdab0 CS fixer 2018-07-24 14:32:52 +02:00
Gabriel Caruso 3d262bd637 Fixes from PHPStan level 0
More fixes from PHPStan level 0
2018-01-14 11:44:15 -02:00
Gabriel Caruso afc9a7643e Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase 2017-11-30 13:44:43 -02:00
Gabriel Caruso a4b220273e Refactoring Tests (#6849) 2017-11-30 15:58:10 +01:00
Nils Adermann 7dffe79a0f Update tests of solver problem message to match new message 2017-11-16 12:41:41 +01:00
Jordi Boggiano 122e422682 CS fixes 2017-03-08 15:16:44 +01:00
rubenrua 4e1887a721 Improve memory usage resolving dependencies
It is known that composer update takes a lot of memory: #5915, #5902,

I am playing with a profiler (@blackfireio) to make a demo in my local
PHP meetup (@phpvigo) and I found out a way to use less memory. These
are my first tests:

* Private project using PHP 5.6:
  * Memory: from 1.31GB to 1.07GB
  * Wall Time: from 2min 8s to 1min 33s

* symfony-demo using PHP 7.1 in my old mac book:
  * Memory: from 667MB to 523MB
  * Wall Time: from  5min 29s to 5min 28s

Not use an array inside conflict rules is this improvement main idea:

```php
<?php
//Memory 38MB
gc_collect_cycles();
gc_disable();

class Rule
{
    public $literals;

    public function __construct(array $literals)
    {
        $this->literals = $literals;
    }
}

$rules = array();

$i = 0;
while ($i<80000){ //
    $i++;

    $array = array(-$i, $i);
    $rule = new Rule($array);
    $rules[] = $rule;
}
```

```php
<?php
//Memory 11.1MB
gc_collect_cycles();
gc_disable();

class Rule2Literals
{
    public $literal1;
    public $literal2;

    public function __construct($literal1, $literal2)
    {
        $this->literal1 = $literal1;
        $this->literal2 = $literal2;
    }
}

$rules = array();

$i = 0;
while ($i<80000){ //
    $i++;

    $rule = new ConflictRule(-$i, $i);
    $rules[] = $rule;
}
```

More info https://github.com/composer/composer/pull/6168
2017-02-20 18:52:17 +00:00
Jordi Boggiano 4cd6eabdba Merge branch '1.2' 2016-10-08 11:27:52 +02:00
Yanick Witschi 4a769a785c Reduce calls on Rule::getHash() 2016-09-30 17:25:41 +02:00
Rob Bast 9cbcda9ae6
add test that asserts pool priority matters
also switch assertEquals for assertSame
2016-09-28 09:34:08 +02:00
Jordi Boggiano 1bd9c8da3c More ruletest fixes for 7.1 2016-04-01 11:58:42 +01:00
Jordi Boggiano c74e6df65d Fix strings being passed to an int arg, fixes 7.1 build 2016-04-01 11:52:19 +01:00
David Prévot 933a8e1d09 Fix method name
It makes the test fail with recent (>= 3.1) phpunit-mock-objects
version.
2016-03-28 23:37:19 -04:00
Niels Keurentjes 8e78ce9a43 Add extra logging before and after SAT solving 2016-03-24 23:19:40 +01:00
Jefferson Carpenter b7845bb6c0 Update SolverTest.php 2016-01-28 20:13:44 -06:00
Rob Bast b523fc0b7b ran fixers 2015-10-13 11:35:51 +02:00
Jordi Boggiano ce08582671 Fix CS 2015-09-28 10:53:24 +01:00
Rob Bast a1427d7fd6 replace all occurences in code and comments 2015-09-24 16:32:36 +02:00
Nils Adermann 6e81f63635 Reduce memory footprint of rules by storing data in blob
Not declaring the job property saves significant amounts of memory as
most rules leave it as null
2015-07-09 17:23:45 +02:00
Nils Adermann b869fa9662 Correct rule hash test 2015-07-08 19:36:13 +02:00
Possum 2e99b9fdf5 Use https where possible 2015-05-04 19:37:57 +02:00
Nils Adermann b4ed331168 The Solver Request no longer depends on the Pool 2015-04-30 17:24:24 +02:00
isoroku e0657b60a2 Fix misspellings 2015-03-20 14:23:24 +00:00
Nicolas Grekas 4a0feb0189 add --prefer-lowest-stable to update command 2014-12-13 11:51:30 +01:00
Nils Adermann 26598c4a9a Remove unnecessary pool reference from rules 2014-12-01 19:02:50 +01:00
Nils Adermann d77400ade2 Make ruleById lookup table in rule set public
Saves about 500k function calls on a packagist update
2014-12-01 18:28:45 +01:00
Jordi Boggiano 94926218e8 CS fixes 2014-10-17 18:57:27 +01:00
Jordi Boggiano ec0463a400 Add tests for platform packages required by root and avoid creating rules altogether instead of disabling them, refs #3320 2014-10-17 15:30:27 +01:00
Nils Adermann 5b80144ad0 Resolve job packages after whitelist generation 2014-02-21 13:41:21 +01:00
Nils Adermann 3148ffd355 Whitelist packages with names matching those specified before generating rules
Addresses #2690 doesn't do any performance optimisations yet which we
could do now
2014-02-21 12:25:15 +01:00
Jordi Boggiano 38917c2047 Add parallel build to travis script 2013-09-25 10:23:48 +02:00
Jordi Boggiano 051d219438 Fix whatProvides returning too many results when no constraint is given 2013-08-12 18:37:34 +02:00
Jordi Boggiano e848c76cbc Only compare branches as versions in the policy to sort packages, but not in the solver, fixes #1817 2013-05-23 18:12:54 +02:00
Jordi Boggiano cc9dac8fe2 Fix tests and convert all package lists to Name[Versions] format 2013-04-27 00:31:22 +02:00
Robert Gruendler 5160dd2f5e Return different error code for SolverProblemsException
To make it easier for external tools to detect SolverProblems and react
to them accordingly,
this PR introduces a new exit code.
2013-04-25 14:37:47 +02:00
Jordi Boggiano b41fd35c2b Remove unused use statement 2013-04-17 18:38:05 +02:00
Jordi Boggiano 0700cd9186 Adjust according to feedback 2013-04-17 17:37:22 +02:00
Jordi Boggiano db4055b778 Put a higher prio on replacers of the same vendor as the required package 2013-04-17 15:39:42 +02:00
Jordi Boggiano b0297ef67a Add prefer-stable flag to pick stable package over unstable ones when possible 2013-04-02 18:40:42 +02:00
Jordi Boggiano 3ca22f9ef1 Fix class name 2013-02-20 15:27:11 +01:00
Jordi Boggiano 1c39ad779b Fix wording 2012-10-31 18:34:27 +01:00
Jordi Boggiano 5d78fa6ce6 Report typos in package name if no version matches 2012-10-31 18:20:54 +01:00
Jordi Boggiano beb9a5bd72 Code optimizations: avoid loops in match() 2012-10-14 16:35:32 +02:00
Jordi Boggiano 18492a1f84 Remove Pool::getMaxId and the solver's reliance on it 2012-10-12 18:45:41 +02:00
Jordi Boggiano fb4183d5ad Fix tests 2012-10-08 20:05:42 +02:00
Jordi Boggiano d4aab7d5b6 Fix solver test 2012-07-11 19:37:02 +02:00
Jordi Boggiano 6573fd3f77 Add hint in solver exceptions as to what may be wrong 2012-07-04 15:57:51 +02:00
Jordi Boggiano 175d1939b5 Fix tests 2012-07-04 14:28:15 +02:00
Jordi Boggiano e6f7150196 Change default minimum-stability to "stable", fixes #744 2012-07-04 14:22:09 +02:00
Jordi Boggiano 4fcc114f97 Merge pull request #808 from palex-fpt/not-equal-operator
Add '<>' operator to Version Parser
2012-06-22 07:00:18 -07:00
Nils Adermann cc7632489d Make problem report messages more readable
Added pretty strings to constraints
2012-06-20 19:06:36 +02:00
Alexey Prilipko e130386612 Add '<>' operator for Version Parser 2012-06-19 12:11:11 +11:00
Grégoire Pineau f4e9dd4fb8 Fixed PSR rules 2012-06-14 12:10:01 +02:00
Nils Adermann a08c2a0b9f Corrected altered error message in test 2012-06-07 11:07:09 +02:00
Nils Adermann 67fde90666 Correctly sort operations within transactions using DFS
Fixes #655
2012-06-05 01:06:35 +02:00
Nils Adermann a7f1605cdf Add test for correct sorting when force installing deps 2012-06-04 23:30:55 +02:00
Nils Adermann 26e051cb76 Decisions are now encapsulated in a separate object 2012-06-04 23:19:32 +02:00
Nils Adermann c869566868 Make ruleHash a protected member of rules 2012-05-20 15:57:38 +02:00
Nils Adermann dd527a4049 Remove weak rules
Since we no longer have suggest/recommend rules and no longer use any update
or feature rules so packages are removed by default, we do not need weak rules
anymore.
2012-05-19 21:49:48 +02:00
Nils Adermann 451bab1c2c Get rid of Literal object / literal id mix, use literals only to save memory 2012-05-19 20:38:56 +02:00
Jordi Boggiano 453b9a616b Add test for Pool handling and refactor a couple things 2012-05-11 17:21:02 +02:00
Nils Adermann 0c1944a9d0 Let the solver handle aliases instead of the installer 2012-05-09 15:15:39 +02:00
Nils Adermann 15f43571b9 Rules of type feature are no longer needed 2012-05-08 19:26:50 +02:00
Nils Adermann c37e126e14 Installed packages are now always removed unless otherwise requested
This means that an update request must always be accompanied by an install
request, otherwise the package might be removed rather than updated.
2012-05-08 19:25:58 +02:00
Nils Adermann 5daeacf0ac We won't implement choice rules, you need to edit composer.json to choose 2012-05-08 19:25:38 +02:00
Jordi Boggiano f7440076fa Revert "Merge remote-tracking branch 'naderman/remove-packages-by-default'"
This reverts commit 2988152602, reversing
changes made to adb4188e12.
2012-04-29 22:21:58 +02:00
Nils Adermann f4d5568937 Rules of type feature are no longer needed 2012-04-27 18:28:51 +02:00
Nils Adermann 2cb2cde096 Installed packages are now always removed unless otherwise requested
This means that an update request must always be accompanied by an install
request, otherwise the package might be removed rather than updated.
2012-04-27 18:13:37 +02:00