DDC-309: ReflectionException when using AbstractQuery::iterate() #385

Closed
opened 2026-01-22 12:36:41 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 9, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user nicokaiser:

When I use two Queries and iterate() over the results, the second one fails with a PHP Fatal error (ReflectionException). It has a strange message ('Class does not exist').
This happens with any two different entities. The error seems to occur when next() is called (directly or via foreach) and the objects are being created.

$q = $em->createQuery('SELECT c FROM Entity\Country c');
$q->iterate()->next();

$q = $em->createQuery('SELECT u FROM Entity\User u');
$q->iterate()->next(); // FAILS

Entities:
http://pastie.org/816374

Example code:
http://pastie.org/816377

Originally created by @doctrinebot on GitHub (Feb 9, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user nicokaiser: When I use two Queries and iterate() over the results, the second one fails with a PHP Fatal error (ReflectionException). It has a strange message ('Class does not exist'). This happens with any two different entities. The error seems to occur when next() is called (directly or via foreach) and the objects are being created. ``` $q = $em->createQuery('SELECT c FROM Entity\Country c'); $q->iterate()->next(); $q = $em->createQuery('SELECT u FROM Entity\User u'); $q->iterate()->next(); // FAILS ``` Entities: http://pastie.org/816374 Example code: http://pastie.org/816377
admin added the Bug label 2026-01-22 12:36:41 +01:00
admin closed this issue 2026-01-22 12:36:41 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 9, 2010):

Comment created by @beberlei:

It seems IterableResult does not support two iterators at once, because it re-uses the hydrator for both queries - effectivly deleting the information from the previous query and destroying the call.

@doctrinebot commented on GitHub (Feb 9, 2010): Comment created by @beberlei: It seems IterableResult does not support two iterators at once, because it re-uses the hydrator for both queries - effectivly deleting the information from the previous query and destroying the call.
Author
Owner

@doctrinebot commented on GitHub (Feb 9, 2010):

Comment created by @beberlei:

Suggested patch

@doctrinebot commented on GitHub (Feb 9, 2010): Comment created by @beberlei: Suggested patch
Author
Owner

@doctrinebot commented on GitHub (Feb 9, 2010):

Comment created by @beberlei:

Fixed! :)

@doctrinebot commented on GitHub (Feb 9, 2010): Comment created by @beberlei: Fixed! :)
Author
Owner

@doctrinebot commented on GitHub (Feb 9, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Feb 9, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/9e9dd10633943efcf4c8

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/9e9dd10633943efcf4c8 - [10358_ddc309.patch](https://gist.github.com/9e9dd10633943efcf4c8#file-10358_ddc309-patch)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#385