-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PoolOptimizer should consider disjunctive MultiConstraints #10579
Fix PoolOptimizer should consider disjunctive MultiConstraints #10579
Conversation
|
||
if ($constraint instanceof MultiConstraint && $constraint->isDisjunctive()) { | ||
foreach ($constraint->getConstraints() as $sub) { | ||
$expanded = array_merge($expanded, $this->expandDisjunctiveMultiConstraints($sub)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the recursion here needed vs simply $expanded[] = $sub;
? I don't think we ever create nested disjunctive constraints but maybe I'm overlooking something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's one of my questions ;) I don't know if it's even possible to define something like (^2.0 || ^3.0) || (^4.1 || ^2.1)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It technically is possible I think, although very uncommon. But we do currently allow multiconstraints to be arbitrarily nested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to work on another testcase then. I want to have this covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brackets are not allowed in version constraints so I don't know how I could create this. I also tried in an actual project and there was no case 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It already is. I just left a comment there to maybe give our future selves an idea where to start debugging if something like this happens. Might want to remove the TODO
or rephrase but I think you have to decide how you'd like to have that note :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah indeed, compact constraint will never have nested disjunction in the output. Disjunction is only used on top level to basically list all the intervals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With that knowledge in mind, we can also drop the hint (and the time-consuming test if you want 😢) 😉 Just let me know what to do :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry had missed that compact was called :( I'd remove it then and maybe just leave a comment that because of the compact that can't exist there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No prob, it helped us find out that it's not a use case so that's good :) This PR is now finished then, I guess.
Thanks for the fix, it makes sense I think. I suppose the perf regression isn't too bad as this kind of constraints isn't so widespread? |
I could not see any regression, no. I actually tested that :) According to blackfire there are other parts that require far more time which is something I want to investigate but that was already the case before this PR. |
I cannot comment in implementation, but I tested the fix on example |
Failing test again unrelated. |
Thanks! |
Fixes #10558
The problem is that we're currently only generating one "dependency constraint group" for disjunctive
MultiConstraint
instances. This means that for^2.14 || ^3.3
we only keep one package that matches this constraint. However, this can go bad as e.g.3.3.0
goes missing in favor of2.14.0
for--prefer-lowest
which might cause an unresolvable set of dependencies whereas3.3.0
would have actually led to a solution.If a
MultiConstraint
is disjunctive, we need to create individual groups for every sub constraint.