DDC-3834: [GH-1465] Spl_object_hash conflict on Merge #4696

Closed
opened 2026-01-22 14:47:48 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Jul 16, 2015).

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of moroine:

Url: https://github.com/doctrine/doctrine2/pull/1465

Message:

This is proper PR which was originally https://github.com/doctrine/doctrine2/pull/1461

Hi,

First of all, this is just a proposal and I'm sure there is a better solution for the problem described here. As this is my first hack into doctrine source code I'm not sure consequences that might be cause by my modification (even all unit tests passes).

I have encounter a problem due to spl_object_hash. I have written a functional test in order to reveal my issue.

The problem is when I merge an entity, here $user, UOW keep data on the original entity identified by it's spl_object_hash. Then if I unset this $user the spl_object_hash is now available for new object. So I experimented in my case reuse of previous hash which cause a managed+dirty entity error.

So I see two solutions

UOW keep reference to the entity given as even the given variable is unset there is remaining reference in UOW so the spl_hash will not be released.
Do not store data about the given entity, as merge operation isn't supposed to modified given entity.
I tried to implement the second solution as the first may consume a much more memory.

I don't why the merge operation need to do this, so I encapsulated it to prevent unwanted bug :)

Originally created by @doctrinebot on GitHub (Jul 16, 2015). Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of moroine: Url: https://github.com/doctrine/doctrine2/pull/1465 Message: This is proper PR which was originally [https://github.com/doctrine/doctrine2/pull/1461](https://github.com/doctrine/doctrine2/pull/1461) Hi, First of all, this is just a proposal and I'm sure there is a better solution for the problem described here. As this is my first hack into doctrine source code I'm not sure consequences that might be cause by my modification (even all unit tests passes). I have encounter a problem due to spl_object_hash. I have written a functional test in order to reveal my issue. The problem is when I merge an entity, here $user, UOW keep data on the original entity identified by it's spl_object_hash. Then if I unset this $user the spl_object_hash is now available for new object. So I experimented in my case reuse of previous hash which cause a managed+dirty entity error. So I see two solutions UOW keep reference to the entity given as even the given variable is unset there is remaining reference in UOW so the spl_hash will not be released. Do not store data about the given entity, as merge operation isn't supposed to modified given entity. I tried to implement the second solution as the first may consume a much more memory. I don't why the merge operation need to do this, so I encapsulated it to prevent unwanted bug :)
admin added the Bug label 2026-01-22 14:47:48 +01:00
admin closed this issue 2026-01-22 14:47:49 +01:00
Author
Owner

@Majkl578 commented on GitHub (Sep 11, 2017):

Handled in related PR #1465.

@Majkl578 commented on GitHub (Sep 11, 2017): Handled in related PR #1465.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4696