mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
AbstractHydrator#iterate() may not cleanup #5562
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @issei-m on GitHub (May 31, 2017).
AFAIK,
AbstractHydrator#iterate()doesn't cleanup anything as long as the iteration doesn't reach the final row.So if I break the loop on the way like following:
The statement cursor is never be closed anymore, this means some file-based DB (like SQLite) may not be released from locking.
Or that is expected result? and these usage is wrong?
@Ocramius commented on GitHub (May 31, 2017):
That currently is the expected result, as hydration is highly dependent on previous results, sadly :-\
I can't remember if we already did this, but each query gets its own hydrator, which mitigates the problem (garbage collection does), when the iterator is released.
@issei-m commented on GitHub (May 31, 2017):
@Ocramius Thanks for your quick response!
First of all, I understood that is the expected result.
However, we have/use the Generator nowaday, so relying on whether iterator has reached to the final row doesn't make sense IMHO.
Could we solve it in 2.x? If so I'm willing to work for this.😏😏
@Ocramius commented on GitHub (May 31, 2017):
No, changing this behavior will most likely cause a BC break here, so I strongly suggest that you try this against
develop(3.x)@issei-m commented on GitHub (May 31, 2017):
I got it. Thanks a lot!
@beberlei commented on GitHub (Dec 8, 2020):
@simPod Looping you into this very old issue here w.r.t. to
toIterable.Could we potentially solve this with a finally statement so that
AbstractHydrator::cleanupis called when the iterable ends in any way?@simPod commented on GitHub (Feb 5, 2021):
@beberlei having a reproducible test case would help. I'll try to examine the execution flow.
@JoniJnm commented on GitHub (Aug 17, 2023):
The problem is here:
5577d51c44/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php (L183-L192)If the loop is broken, the cleanup is not executed. One possible solution is to wrap the while into a try-finally:
@oleg-andreyev commented on GitHub (Apr 19, 2024):
Today found exact same issue.
toIterabletoIterablecreates new hydrator but event-manager is shared number of onClear listeners are growing because cleanup in not called after iterating all results.