Skip to content

Fix CursorPaginator cursors ordered by a field of a joined entity - #12719

Closed
GromNaN wants to merge 1 commit into
doctrine:3.7.xfrom
GromNaN:fix/cursor-paginator-joined-field
Closed

GromNaN wants to merge 1 commit into
doctrine:3.7.xfrom
GromNaN:fix/cursor-paginator-joined-field

Conversation

@GromNaN

@GromNaN GromNaN commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Building a cursor for an ORDER BY on a joined alias read the value from the root item, so ORDER BY a.number crashed with Call to a member function getValue() on null.

CursorWalker now records the single-valued associations from the root alias to the item's alias, and CursorPaginator follows them to read the value. Proxies are initialized, a null association yields a null cursor value, and an alias reached through a collection throws a LogicException. Scalar and mixed results are not covered.

Tests cover a selected joined entity, an unselected one behind a proxy, a DTO result, and a collection join.

Based on #12671 by @guillaume-sainthillier.

Fixes #12670.

getParametersForItem() read every ORDER BY value from the result item, even
when the ORDER BY item was on a joined alias, so building a cursor crashed
with "Call to a member function getValue() on null".

CursorWalker now records the single-valued associations that lead from the
root alias to the item's alias, and CursorPaginator follows them to read the
value. Proxies are initialized, a null association yields a null cursor value,
and an alias reached through a collection is rejected with a LogicException.
Results that are not entities keep reading the property named after the field.

Based on doctrine#12671 by Guillaume Sainthillier.

Co-authored-by: Guillaume Sainthillier <guillaume.sainthillier@gmail.com>
@GromNaN GromNaN closed this Oct 30, 2026
@GromNaN
GromNaN deleted the fix/cursor-paginator-joined-field branch October 30, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CursorPaginator crashes building a cursor when ordering by a field of a joined entity

1 participant