mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Strange dirty behavior in PersistentCollection #4967
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 @mmoreram on GitHub (Jan 8, 2016).
Scenario
The mapping code
We have the Purchasable mapping file (abstract one)
And we have the specific Product mapping file (Extends Purchasable)
The crashing code
This code is part of a service.
productObjectManagercan be considered as the default entity manager. The exception is produced by the second call.Some tips
When I do flush in the first time, the Collection of Category instances is set to dirty. After some investigation, https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L607 this line is the one that set this value.
Commenting this line, everything works as expected (I know that that's not an option), but I would like to understand what implies this line and why is there.
Any help please?
Any idea of what could be the issue?
@billschaller commented on GitHub (Jan 8, 2016):
Can you make a gist containing the entities and persistance code leading to the error?
@mmoreram commented on GitHub (Jan 8, 2016):
@zeroedin-bill Updated :)
@billschaller commented on GitHub (Jan 8, 2016):
Hmm. I haven't seen someone use interfaces as targetEntity before, but I really don't know what is going on here. @Ocramius, @guilhermeblanco, any ideas?
@mmoreram commented on GitHub (Jan 8, 2016):
@zeroedin-bill the resolve target entity does the work :)
http://symfony.com/doc/current/cookbook/doctrine/resolve_target_entity.html
@mmoreram commented on GitHub (Jan 8, 2016):
ping @acasademont
@mmoreram commented on GitHub (Jan 11, 2016):
I got it.
Look at this piece of code.
What happens here?
Even if categories are the same, because the object is no longer a PersistentCollection but an ArrayCollection, the element if marked as dirty and is recomputed again as inserts.
I would love to understand why, so I will continue digging in the project, but if you can give me some light, would be nice :)
@zeroedin-bill @Ocramius
@billschaller commented on GitHub (Jan 11, 2016):
@mmoreram I think we'd really need a failing test case to fully understand what's going on here...
@mmoreram commented on GitHub (Jan 11, 2016):
Yes. That's what I working on now :)
@billschaller commented on GitHub (Jan 11, 2016):
👍