mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-675: EntityManager->find() returns detached (or otherwise unmanaged) object. #831
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 (Jul 9, 2010).
Jira issue originally created by user napsi:
The find method seems to be broken. Returned objects are not managed according to the EntityManager. Fetching the same object via findAll() works.
This gives me:
Class: net\jay\products\doctrine\ProductEntityType
Contained: No
@doctrinebot commented on GitHub (Jul 9, 2010):
Comment created by @beberlei:
can you try to build a reproducible test-case? This would be a serious issue, however we cannot reproduce it this way.
@doctrinebot commented on GitHub (Jul 9, 2010):
Comment created by napsi:
Ah it turns out to be the leading namespace \ in the find parameter that killed me. Without it, the object turns out managed.
Slightly troublesome that the object is returned in both cases perhaps.
I tested with this added to tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php, in case the behaviour needs to be changed:
Find1 passes, while Find2 fails. The user is found in both cases though.
Have a nice weekend. :)
@doctrinebot commented on GitHub (Jul 9, 2010):
Comment created by romanb:
That is because the objects are stored in the identity map based on their class name. We could strip off leading backslashes but once we start doing that we will always miss some places. Class names in strings are always fully-qualified, thus there is never a need to use a leading backslash in a string that contains a class name. The leading backslash is only useful in actual code, not in strings.
@doctrinebot commented on GitHub (Jul 9, 2010):
Comment created by napsi:
Maybe just mentioning it in a "common use errors" section of the manual could be a good solution to avoid too much despair when the \ is added by mistake. If it's not already mentioned in there somewhere.
@doctrinebot commented on GitHub (Jul 20, 2010):
Comment created by obrys:
The solution is just add a warning when leading \ is found.
The same bug happends to me. It took lots of hours to find that it was by .
Thanks
obrys
@doctrinebot commented on GitHub (Aug 8, 2010):
Comment created by romanb:
Fixed.
@doctrinebot commented on GitHub (Aug 8, 2010):
Issue was closed with resolution "Fixed"