248 Commits (3cdca37e8588d262efbb3b589f8a68eea73738a2)

Author SHA1 Message Date
Nils Adermann f1e4ccbe1d Fix handling of reference updates and root references 5 years ago
Jordi Boggiano 6c4357a7ed
Merge branch 'master' into 2.0 5 years ago
Gabriel Caruso 1d05d4171c
Remove unused private methods 5 years ago
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
  ...
5 years ago
Jordi Boggiano 799717f102
Tweak and fix some more phpstan reports 5 years ago
Jordi Boggiano fb3d0981c0
Fix test suite 5 years ago
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
5 years ago
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
5 years ago
Nils Adermann 29ff6a40ae Follow up to #7946 test: add solver flag to assert path execution 5 years ago
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
5 years ago
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.
5 years ago
Jordi Boggiano 2e0f31106a Merge remote-tracking branch 'origin/master' into 2.0 6 years ago
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
6 years ago
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
6 years ago
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
6 years ago
Nils Adermann b6e2d60c9e Create the pool in the installer before giving it to the solver 6 years ago
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
6 years ago
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
6 years ago
Jordi Boggiano ff59bbdab0 CS fixer 6 years ago
Gabriel Caruso 3d262bd637 Fixes from PHPStan level 0
More fixes from PHPStan level 0
7 years ago
Gabriel Caruso afc9a7643e Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase 7 years ago
Gabriel Caruso a4b220273e Refactoring Tests (#6849) 7 years ago
Nils Adermann 7dffe79a0f Update tests of solver problem message to match new message 7 years ago
Jordi Boggiano 122e422682 CS fixes 7 years ago
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
7 years ago
Jordi Boggiano 4cd6eabdba Merge branch '1.2' 8 years ago
Yanick Witschi 4a769a785c Reduce calls on Rule::getHash() 8 years ago
Rob Bast 9cbcda9ae6
add test that asserts pool priority matters
also switch assertEquals for assertSame
8 years ago
Jordi Boggiano 1bd9c8da3c More ruletest fixes for 7.1 8 years ago
Jordi Boggiano c74e6df65d Fix strings being passed to an int arg, fixes 7.1 build 8 years ago
David Prévot 933a8e1d09 Fix method name
It makes the test fail with recent (>= 3.1) phpunit-mock-objects
version.
8 years ago
Niels Keurentjes 8e78ce9a43 Add extra logging before and after SAT solving 8 years ago
Jefferson Carpenter b7845bb6c0 Update SolverTest.php 9 years ago
Rob Bast b523fc0b7b ran fixers 9 years ago
Jordi Boggiano ce08582671 Fix CS 9 years ago
Rob Bast a1427d7fd6 replace all occurences in code and comments 9 years ago
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
9 years ago
Nils Adermann b869fa9662 Correct rule hash test 9 years ago
Possum 2e99b9fdf5 Use https where possible 9 years ago
Nils Adermann b4ed331168 The Solver Request no longer depends on the Pool 9 years ago
isoroku e0657b60a2 Fix misspellings 9 years ago
Nicolas Grekas 4a0feb0189 add --prefer-lowest-stable to update command 10 years ago
Nils Adermann 26598c4a9a Remove unnecessary pool reference from rules 10 years ago
Nils Adermann d77400ade2 Make ruleById lookup table in rule set public
Saves about 500k function calls on a packagist update
10 years ago
Jordi Boggiano 94926218e8 CS fixes 10 years ago
Jordi Boggiano ec0463a400 Add tests for platform packages required by root and avoid creating rules altogether instead of disabling them, refs #3320 10 years ago
Nils Adermann 5b80144ad0 Resolve job packages after whitelist generation 11 years ago
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
11 years ago
Jordi Boggiano 38917c2047 Add parallel build to travis script 11 years ago
Jordi Boggiano 051d219438 Fix whatProvides returning too many results when no constraint is given 11 years ago
Jordi Boggiano e848c76cbc Only compare branches as versions in the policy to sort packages, but not in the solver, fixes #1817 11 years ago
Jordi Boggiano cc9dac8fe2 Fix tests and convert all package lists to Name[Versions] format 11 years ago
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.
11 years ago
Jordi Boggiano b41fd35c2b Remove unused use statement 11 years ago
Jordi Boggiano 0700cd9186 Adjust according to feedback 11 years ago
Jordi Boggiano db4055b778 Put a higher prio on replacers of the same vendor as the required package 11 years ago
Jordi Boggiano b0297ef67a Add prefer-stable flag to pick stable package over unstable ones when possible 11 years ago
Jordi Boggiano 3ca22f9ef1 Fix class name 12 years ago
Jordi Boggiano 1c39ad779b Fix wording 12 years ago
Jordi Boggiano 5d78fa6ce6 Report typos in package name if no version matches 12 years ago
Jordi Boggiano beb9a5bd72 Code optimizations: avoid loops in match() 12 years ago
Jordi Boggiano 18492a1f84 Remove Pool::getMaxId and the solver's reliance on it 12 years ago
Jordi Boggiano fb4183d5ad Fix tests 12 years ago
Jordi Boggiano d4aab7d5b6 Fix solver test 12 years ago
Jordi Boggiano 6573fd3f77 Add hint in solver exceptions as to what may be wrong 12 years ago
Jordi Boggiano 175d1939b5 Fix tests 12 years ago
Jordi Boggiano e6f7150196 Change default minimum-stability to "stable", fixes #744 12 years ago
Jordi Boggiano 4fcc114f97 Merge pull request #808 from palex-fpt/not-equal-operator
Add '<>' operator to Version Parser
12 years ago
Nils Adermann cc7632489d Make problem report messages more readable
Added pretty strings to constraints
12 years ago
Alexey Prilipko e130386612 Add '<>' operator for Version Parser 12 years ago
Grégoire Pineau f4e9dd4fb8 Fixed PSR rules 12 years ago
Nils Adermann a08c2a0b9f Corrected altered error message in test 12 years ago
Nils Adermann 67fde90666 Correctly sort operations within transactions using DFS
Fixes #655
12 years ago
Nils Adermann a7f1605cdf Add test for correct sorting when force installing deps 12 years ago
Nils Adermann 26e051cb76 Decisions are now encapsulated in a separate object 12 years ago
Nils Adermann c869566868 Make ruleHash a protected member of rules 12 years ago
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.
12 years ago
Nils Adermann 451bab1c2c Get rid of Literal object / literal id mix, use literals only to save memory 12 years ago
Jordi Boggiano 453b9a616b Add test for Pool handling and refactor a couple things 12 years ago
Nils Adermann 0c1944a9d0 Let the solver handle aliases instead of the installer 12 years ago
Nils Adermann 15f43571b9 Rules of type feature are no longer needed 12 years ago
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.
12 years ago
Nils Adermann 5daeacf0ac We won't implement choice rules, you need to edit composer.json to choose 12 years ago
Jordi Boggiano f7440076fa Revert "Merge remote-tracking branch 'naderman/remove-packages-by-default'"
This reverts commit 2988152602, reversing
changes made to adb4188e12.
12 years ago
Nils Adermann f4d5568937 Rules of type feature are no longer needed 12 years ago
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.
12 years ago
Nils Adermann 0e537b9c93 We won't implement choice rules, you need to edit composer.json to choose 12 years ago
Jordi Boggiano 06fb1b8083 Fix priority of aliases when mixing root package aliases with branch-alias ones, fixes #576 12 years ago
Nils Adermann a16aa68c1d Rule literals are sorted, so first literal added is not first retrieved
Fixes #477
12 years ago
Nils Adermann 2c87fe5a22 Collect solver problems in Problem objects with human readable output. 12 years ago
Martin Hasoň 2b08df5192 Changed repository priority in the pool 13 years ago
Nils Adermann f3ff53b17c Create problems directly, rather than generating impossible rules 13 years ago
Nils Adermann dd443cd570 Complete circular dependency with alternatives through virtual packages test 13 years ago
Nils Adermann 3e1749fbad Readd update-all jobs and make them available through the request 13 years ago
Nils Adermann 9b8e62396c Merge pull request #324 from edorian/installNonExistingPackage
Create an 'impossible rule' when installing non existent packages
13 years ago
Nils Adermann 3b06a22e69 Add getVersionConstraint test case to avoid version normalization issues 13 years ago
Volker Dusch f304a0f129 Clean up the incomplete marker like suggested in https://github.com/composer/composer/pull/324#r465391 13 years ago
Nils Adermann 1ee5d99405 When changing watched literals of a rule, update the parent's next pointer
The previous rule was not previously updated to point to the next rule when
removing a middle rule from the watch tree for a literal. This resulted in
jumping from one literal's watch tree to another's, which could then jump
back to the original and cause infinite loop in a case like #265.

Fixes #265
13 years ago
Volker Dusch e20a79ac61 Fix TODO tags to confirm with the projects standard 13 years ago
Volker Dusch eafe13d5a5 Create an impossible rule when trying to install something that doesn't exist.
The rule isn't acted upon yet (hence the incomplete test) but it is there as a reminder that this case needs to be handled.
13 years ago
Nils Adermann e6143d1584 Add todos to explain why try/catch is inside the test 13 years ago
Nils Adermann 52d876e11e Add SolverProblemsException and test basic solver failures 13 years ago
Volker Dusch 3fb75faa75 Now that no more update rules are created the code that handles them can be removed too.
Also adapted the tests that used TYPE_UPDATE exemplarily to use TYPE_FEATURE.
13 years ago
Volker Dusch a8b2db64d5 Expaned the update tests to make sure a) Only requested updates execute and b) Installed repos with no actions get pruned from the jobqueue 13 years ago
Nils Adermann 8aa0127de8 Remove test of undefined behaviour for unknown types in rulesets 13 years ago
Nils Adermann 7609f27052 Merge branch 'add-tests' of https://github.com/l3l0/composer into new-master
* 'add-tests' of https://github.com/l3l0/composer:
  Made fixes after review.
  Made changes which fied warnings and errors in tests.
  Fixed tests after update and merge of changes from upstream/master
  Fixed code. Changes improved code testability
  Added and extended some unit tests
13 years ago
Nils Adermann 460822fb96 Fix indentation of doc comment 13 years ago
Nils Adermann 3b54316e91 Add a test for the off by one error in solver conflict resolution 13 years ago
Leszek Prabucki f59ca1e2f8 Made fixes after review. 13 years ago
Leszek Prabucki de7f666118 Added and extended some unit tests 13 years ago
Jordi Boggiano 098ba8e583 Add test 13 years ago
Jordi Boggiano 8cfbf9e198 Fix update, fixes #125 13 years ago
Nils Adermann a0faa4f69f Add a test for the complex conflict resolution fixed in #118 13 years ago
Jordi Boggiano 8e6f8ae57e Add prettyVersion to packages, fixes #76 13 years ago
Nils Adermann 4140f08d9c Use a map of installed package ids in the solver
The assumption package.repo == installed no longer holds for installed
packages because there are multiple wrapped installed repositories.
13 years ago
Nils Adermann e16c3f0626 Remove useless test, packages providing different versions aren't alternatives 13 years ago
Nils Adermann 0801d8ed31 Enable solver test regarding replaced packages after policy fix 13 years ago
Nils Adermann 571c14adf9 Prefer original packages over replaced packages of same repository priority 13 years ago
Nils Adermann 1b6f57e651 Correctly implement priorities and version numbers in the default policy 13 years ago
Nils Adermann 55d5e55195 DefaultPolicy test: pick package providing newest virtual package version 13 years ago
Nils Adermann 0c30610fdc Complete the policy tests with provider and replacement tests 13 years ago
Nils Adermann e4c94dd415 Adding tests for the default policy specifying its desired behaviour 13 years ago
Jordi Boggiano 40cc5fea1d Add a few solver tests regarding "replace" 13 years ago
Nils Adermann 30f6c05069 Add test for choices in circular requirements and delete packagist based test 13 years ago
Nils Adermann 85f88de59d Add a solver test for provided virtual packages and circular dependencies 13 years ago
everzet 123f5fef77 Refactored Operations in order to fulfill naderman requests 13 years ago
Jordi Boggiano 6d667a849e Remove broken functional test 13 years ago
everzet 0a1e7320b0 Refactored solver result array. Now it returns array of operation objects which are much nicer to work with 13 years ago
Nils Adermann b1d16a88b7 Test a replace link with a null constraint between packages 13 years ago
Nils Adermann 69ebbf0eac Correct handling of rules with more than 2 literals. 13 years ago
Nils Adermann db18e1b560 Add a few proper tests for literals, all tests passing now 13 years ago
Nils Adermann ac61c3973b Add a test for two equivalent installable packages and fix the functional test 13 years ago
Nils Adermann 0f6fb9b692 Separate transaction generation from solving and properly identify updates 13 years ago
Nils Adermann f46aa495da Turn obsolete relationships and replaced packages into conflict rules 13 years ago
Nils Adermann ad25618bdd Add install job and update rule conflict handling and reenable installation 13 years ago
Nils Adermann 1125de6bf2 Added disablePolicyRules to solve conflicts between remove jobs & update rules
This temporarily breaks installation of packages
13 years ago
Nils Adermann 01945c20f9 Simplify testSolverWithComposerRepo reusing utility methods from other tests 13 years ago
Nils Adermann 172c8b908e Split the large solver test up into individual units testing smaller parts 13 years ago
Jordi Boggiano b277b8e73c Add failing test with composer repo 13 years ago
Jordi Boggiano 2d1f8fbe70 LiteralTest is incomplete 13 years ago
Nils Adermann 825deff09f Completed analysis of unsolvable situations and main decision process 13 years ago
Nils Adermann bc672deb32 Moving rule iteration logic to a separate RuleSet and RuleSetIterator class 13 years ago
Nils Adermann 498125adbe Assertions are now properly decided before running the main solver.
Updating does not work yet. The test case works fine for installing/removing
the correct packages however. Weak (update/feature) rules are entirely ignored
so far.

Watches are on literal ids rather than literals to save on function calls
and memory usage. So a few methods for literals now have an id counter part.
This should probably be refactored to have the literal versions call the
id ones instead.
13 years ago
Jordi Boggiano d181e32000 Fixed test expectation 13 years ago
Jordi Boggiano 00260a89ae Make test fail 13 years ago
Jordi Boggiano c6321e7277 Fix tests and invalid use statements 13 years ago
Jordi Boggiano 7ea2fd6c93 Fix author/copyright 13 years ago
Nils Adermann 933cc6179b Import initial partial port of the libzypp satsolver. 13 years ago