Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnitOfWork and spl_object_hash uniqueness #1655

Closed
mmucklo opened this issue Oct 14, 2017 · 3 comments
Closed

UnitOfWork and spl_object_hash uniqueness #1655

mmucklo opened this issue Oct 14, 2017 · 3 comments
Labels
Needs Test Stale Issues that have not seen any activity in 30 days

Comments

@mmucklo
Copy link

mmucklo commented Oct 14, 2017

UnitOfWork relies on spl_object_hash being unique. However if an object gets destroyed (garbage collected), a new object can receive the same spl_object_hash.

http://php.net/manual/en/function.spl-object-hash.php

I'm seeing a case where an object has been recycled, but the $documentStates map inside of lib/Doctrine/ODM/MongoDB/UnitOfWork.php still contains a reference to that object.

So when a new object is created and attempted to be saved, UnitOfWork thinks it's not new, causing quite the problem...

@malarzm
Copy link
Member

malarzm commented Oct 14, 2017

@mmucklo any chance you could provide a failing test case? Theory is, that UnitOfWork keeps reference to each managed document (embedded documents included) which effectively will prevent that object to be picked by a garbage collector. If there is a scenario that doesn't clean everything it should, we should fix that.

@mmucklo
Copy link
Author

mmucklo commented Oct 14, 2017

I was seeing the issue break some of my phpunit test cases. I've since worked around it bit calling ->clear() on the DocumentManager...

@stale
Copy link

stale bot commented Jan 21, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Issues that have not seen any activity in 30 days label Jan 21, 2019
@stale stale bot closed this as completed Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Test Stale Issues that have not seen any activity in 30 days
Projects
None yet
Development

No branches or pull requests

2 participants