Skip to content

Clone query hints and parameters in LimitSubqueryOutputWalker constructor#11826

Merged
greg0ire merged 1 commit intodoctrine:2.20.xfrom
aprat84:gh-11741
Feb 12, 2025
Merged

Clone query hints and parameters in LimitSubqueryOutputWalker constructor#11826
greg0ire merged 1 commit intodoctrine:2.20.xfrom
aprat84:gh-11741

Conversation

@aprat84
Copy link
Copy Markdown
Contributor

@aprat84 aprat84 commented Feb 5, 2025

Fixes #11741

Should be merged up to at least v2.20.0 and v3.3.0.

The problem seems to be that LimitSubqueryOutputWalker clones the Query object, but not its hints (including the fetchMode hint, which causes the issue).
Don't know if cloning the parameters is really needed.
Been inspired on what the class Paginator does when cloning a Query.
Suggestions are welcome!

@aprat84 aprat84 force-pushed the gh-11741 branch 2 times, most recently from 2ebf558 to 52b1cdb Compare February 6, 2025 09:45
…ctor

This fixes a bug that arises when using Pagination and an entity relation is mapped with fetch-mode EAGER but setFetchMode LAZY (or anything that is not EAGER) has been used on the query. If the query use WITH condition, an exception is incorrectly raised (Associations with fetch-mode=EAGER may not be using WITH conditions).
The class LimitSubqueryOutputWalker clones the query, but not its parameters and hints, so the generated subquery does not know that fetch-mode has been overridden.

Fixes doctrine#11741
@greg0ire greg0ire added the Bug label Feb 12, 2025
@greg0ire greg0ire added this to the 2.20.3 milestone Feb 12, 2025
@greg0ire greg0ire merged commit 2c2ef65 into doctrine:2.20.x Feb 12, 2025
74 checks passed
@greg0ire
Copy link
Copy Markdown
Member

Thanks @aprat84 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants