Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12585
Selecting the same identification variable twice, e.g.
SELECT u, p, p FROM CmsUser u LEFT JOIN u.phonenumbers p, silently disabled the fetch join: the data was correct, but every collection stayed uninitialized and was lazy loaded with one query per parent row.Parser::$identVariableExpressionskept one select expression per alias, so the secondpreplaced the first.fixIdentificationVariableOrder()only moves the expressions it knows about, so the firstpwas left at the head of the select clause, ahead of its parentu. The hydrator then met the child before the parent and dropped the association from the fetched hints for the whole result.The parser now keeps every select expression of an alias and moves all of them. Nothing is added to or removed from the AST, so queries without a repeated alias produce the same SQL as before.
The test covers an entity result and a mixed result (entity plus scalar); both fail without the fix.
Targeting 2.20.x as the lowest maintained branch, the code is the same on 3.x. On 3.x the property is typed (
private array), so merging up conflicts on the docblock line only.AI-assisted: I used Claude Code to locate the cause and draft the fix and the test. I reviewed the change, ran the full test suite, phpcs and PHPStan locally, and can explain every line of it.