Fetch mode hint is ignored when using Paginator #7446

Closed
opened 2026-01-22 15:51:46 +01:00 by admin · 3 comments
Owner

Originally created by @aprat84 on GitHub (Nov 28, 2024).

Bug Report

Q A
Version 2.20.0 / 3.3.0
Previous working version 2.19.8 / 3.2.3

Summary

This is related to issue #11128 and PR #11445.

When a fetch=EAGER association is filtered using WITH, it raises an error unless fetch mode is overridden by calling setFetchMode(LAZY) over the association.

This worked well after the fix in #11445.

Somehow, in 2.20.x and 3.3.x this bug returned, partially, only when using Paginator with fetchJoinCollection parameter set to true.

Seems like #11188 introduced this bug.

Current behavior

An exception is raised even when fetch mode is overridden.

Expected behavior

It should work the same with or without pagination.

How to reproduce

See test in https://github.com/aprat84/orm/tree/gh-11741

vendor/bin/phpunit --filter testSubselectFetchJoinWithAllowedWhenOverriddenNotEagerPaginator

There was 1 error:

1) Doctrine\Tests\ORM\Functional\EagerFetchCollectionTest::testSubselectFetchJoinWithAllowedWhenOverriddenNotEagerPaginator
Doctrine\ORM\Query\QueryException: Associations with fetch-mode=EAGER may not be using WITH conditions in "Doctrine\Tests\ORM\Functional\EagerFetchChild#owner".
Originally created by @aprat84 on GitHub (Nov 28, 2024). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |-------------------------------------------- | -------------- | Version | 2.20.0 / 3.3.0 | Previous working version | 2.19.8 / 3.2.3 #### Summary This is related to issue #11128 and PR #11445. When a `fetch=EAGER` association is filtered using `WITH`, it raises an error unless fetch mode is overridden by calling `setFetchMode(LAZY)` over the association. This worked well after the fix in #11445. Somehow, in 2.20.x and 3.3.x this bug returned, partially, only when using `Paginator` with `fetchJoinCollection` parameter set to `true`. Seems like #11188 introduced this bug. #### Current behavior An exception is raised even when fetch mode is overridden. #### Expected behavior It should work the same with or without pagination. #### How to reproduce See test in https://github.com/aprat84/orm/tree/gh-11741 ``` vendor/bin/phpunit --filter testSubselectFetchJoinWithAllowedWhenOverriddenNotEagerPaginator There was 1 error: 1) Doctrine\Tests\ORM\Functional\EagerFetchCollectionTest::testSubselectFetchJoinWithAllowedWhenOverriddenNotEagerPaginator Doctrine\ORM\Query\QueryException: Associations with fetch-mode=EAGER may not be using WITH conditions in "Doctrine\Tests\ORM\Functional\EagerFetchChild#owner". ```
admin closed this issue 2026-01-22 15:51:47 +01:00
Author
Owner

@aprat84 commented on GitHub (Dec 9, 2024):

Seems like #11188 introduced this bug. Commits were squashed apparently, so can't test them separately.

@mpdude @greg0ire

@aprat84 commented on GitHub (Dec 9, 2024): Seems like #11188 introduced this bug. Commits were squashed apparently, so can't test them separately. @mpdude @greg0ire
Author
Owner

@aprat84 commented on GitHub (Feb 4, 2025):

@mpdude can you take a look at while you may still have fresh memory of what you did in #11188?

This is preventing me to update to next minor...

@aprat84 commented on GitHub (Feb 4, 2025): @mpdude can you take a look at while you may still have fresh memory of what you did in #11188? This is preventing me to update to next **minor**...
Author
Owner

@aprat84 commented on GitHub (Feb 5, 2025):

I looked into it a little bit, and I think the problem is that in LimitSubqueryOutputWalker the Query is cloned, but not the hints:

73e68f3c7d/src/Tools/Pagination/LimitSubqueryOutputWalker.php (L108)

Don't know if parameters also need to be cloned, as it is done in 73e68f3c7d/src/Tools/Pagination/Paginator.php (L183)

@aprat84 commented on GitHub (Feb 5, 2025): I looked into it a little bit, and I think the problem is that in `LimitSubqueryOutputWalker` the `Query` is cloned, but not the hints: https://github.com/doctrine/orm/blob/73e68f3c7dfe657febb0790f339b0dfcc1c0a079/src/Tools/Pagination/LimitSubqueryOutputWalker.php#L108 Don't know if parameters also need to be cloned, as it is done in https://github.com/doctrine/orm/blob/73e68f3c7dfe657febb0790f339b0dfcc1c0a079/src/Tools/Pagination/Paginator.php#L183
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7446