mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3619: spl_object_hash collision #4445
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 @doctrinebot on GitHub (Mar 17, 2015).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user Akhristenko:
The code below demonstrate problem.
@doctrinebot commented on GitHub (Mar 17, 2015):
@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by @ocramius:
{quote}spl_object_hash($user2) may be equal to spl_object_hash($user) because $user has no reference{quote}
this seems wrong, since
$userwon't get garbage collected@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by Akhristenko:
Why? The $user has no reference to it, so it may be collected.
I use SoftDeleteabale extension and faced with this problem.
My code is look like:
@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by @ocramius:
[~Akhristenko] the UoW has an internal reference to
$user, so it cannot be garbage collected@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by @ocramius:
I suggest abstracting this problem into a test case in order to remove these doubts upfront.
@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by Akhristenko:
{quote}
Aleksandr Khristenko the UoW has an internal reference to $user, so it cannot be garbage collected
{quote}
Yes, but when we call remove($entity) this internal reference move from identityMap to entityDeletions array. And when we after that call persist($entity) this internal reference remove from entityDeletions array but NOT added to identityMap. So, after that UoW has not an internal reference to $user.
@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by Akhristenko:
I attached the test, which demonstrates that reference to entity from UoW is lost.
@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by nclavaud:
I am also using SoftDeleteable Doctrine extension (https://github.com/Atlantic18/DoctrineExtensions) and facing a similar issue.
My scenario is:
Problem is: 1 of the 3 entities won't be persisted (same $oid than one of the soft-deleted ones).
I've created a PR here that solves my issue:
https://github.com/doctrine/doctrine2/pull/1338
Does it make sense to you?
@doctrinebot commented on GitHub (Mar 17, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1338] was closed:
https://github.com/doctrine/doctrine2/pull/1338
@doctrinebot commented on GitHub (Mar 17, 2015):
Issue was closed with resolution "Fixed"