PersistentCollection::removeElement with fetch EXTRA_LAZY remove from DB without persist&flush #6242

Open
opened 2026-01-22 15:29:28 +01:00 by admin · 4 comments
Owner

Originally created by @karakum on GitHub (May 31, 2019).

Originally assigned to: @karakum on GitHub.

Bug Report

Q A
BC Break yes/no
Version 2.6.3

Summary

This code was added a long-long ago in 2011 year...
356f5874bf (r33750844)

Current behavior

$collection->removeElement($el) execute sql DELETE before(without) $em->persist()&$em->flush().

How to reproduce

1 Many-to-many collection with fetch="EXTRA_LAZY"
2 Remove element from collection

Expected behavior

There must no DB changes be made without $em->persist()&$em->flush()

Originally created by @karakum on GitHub (May 31, 2019). Originally assigned to: @karakum on GitHub. ### Bug Report | Q | A |------------ | ------ | BC Break | yes/no | Version | 2.6.3 #### Summary This code was added a long-long ago in 2011 year... https://github.com/doctrine/orm/commit/356f5874bf81ca4e37681c233e24cc84d16e7a39#r33750844 #### Current behavior `$collection->removeElement($el)` execute sql DELETE before(without) `$em->persist()`&`$em->flush()`. #### How to reproduce 1 Many-to-many collection with `fetch="EXTRA_LAZY"` 2 Remove element from collection #### Expected behavior There must no DB changes be made without `$em->persist()`&`$em->flush()`
admin added the BugMissing Tests labels 2026-01-22 15:29:28 +01:00
Author
Owner

@lcobucci commented on GitHub (Oct 2, 2019):

@karakum changes might still happen without $em->persist(), depending on the tracking policy. However, $em->flush() is a must. Would you be able to send us a functional test reproducing this issue? It would be quite helpful 👍

@lcobucci commented on GitHub (Oct 2, 2019): @karakum changes might still happen without `$em->persist()`, depending on the tracking policy. However, `$em->flush()` is a must. Would you be able to send us a functional test reproducing this issue? It would be quite helpful :+1:
Author
Owner

@lcobucci commented on GitHub (Oct 2, 2019):

@karakum never mind my comment, this is apparently the way things are designed to work (TIL!)

@lcobucci commented on GitHub (Oct 2, 2019): @karakum never mind my comment, this is apparently the way things are designed to work (TIL!)
Author
Owner

@karakum commented on GitHub (Oct 2, 2019):

@lcobucci could you please give me doc-link about this "feature"?

@karakum commented on GitHub (Oct 2, 2019): @lcobucci could you please give me doc-link about this "feature"?
Author
Owner

@lcobucci commented on GitHub (Oct 2, 2019):

@karakum unfortunately, there's just no documentation for that: https://github.com/doctrine/orm/issues/7765

Changing this is a BC break but I believe we have to find a solution to overcome what @guilhermeblanco mentioned in the commit and still make this managed by the UoW.

@lcobucci commented on GitHub (Oct 2, 2019): @karakum unfortunately, there's just no documentation for that: https://github.com/doctrine/orm/issues/7765 Changing this is a BC break but I believe we have to find a solution to overcome what @guilhermeblanco mentioned in the commit and still make this managed by the UoW.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6242