1
0
Fork 0
mirror of synced 2025-04-01 20:36:14 +03:00
doctrine2/tests/Doctrine/Tests
Mathieu De Zutter 01d51bfca3 Avoid conflicts due to spl_object_hash().
When merging an entity with a to-many association, it will store the
original entity data using the object hash of the to-be-merged entity
instead of the managed entity. Since this to-be-merged entity is not
managed by Doctrine, it can disappear from the memory. A new object
can reuse the same memory location and thus have the same object hash.
When one tries to persist this object as new, Doctrine will refuse it
because it thinks that the entity is managed+dirty.

This patch is a very naive fix: it just disables storing the original
entity data in case of to-many associations. It may not be the ideal
or even a good solution at all, but it solves the problem of object
hash reuse.

The test case relies on the immediate reusing of memory locations by
PHP. The variable $user has twice the same object hash, though referring
a different object. Tested on PHP 5.6.17

Without the fix, the test fails on the last line with:
A managed+dirty entity Doctrine\Tests\Models\CMS\CmsUser@[...] can not
be scheduled for insertion.
2016-09-09 23:22:31 +02:00
..
DbalTypes #1336 - class constants over string references in tests - removing useless QueryBuilder usage 2015-03-17 21:21:20 +00:00
EventListener Remove full qualified class names in tests 2016-05-11 03:00:44 +07:00
Mocks Optimize imports. Remove full qualified class names 2016-05-11 01:55:12 +07:00
Models PR fixes (public properties & correct letter case in annotations) 2016-09-08 13:37:00 +02:00
ORM Avoid conflicts due to spl_object_hash(). 2016-09-09 23:22:31 +02:00
DbalFunctionalTestCase.php Fixed documentation for Doctrine\Tests 2012-12-14 18:55:49 +00:00
DbalTestCase.php Fixed documentation for Doctrine\Tests 2012-12-14 18:55:49 +00:00
DoctrineTestCase.php Fixed documentation for Doctrine\Tests 2012-12-14 18:55:49 +00:00
OrmFunctionalTestCase.php Create a failing test for issue #5989 2016-09-08 13:37:00 +02:00
OrmPerformanceTestCase.php Updated syntax for ``integer` and `boolean`` types 2015-07-14 15:30:13 -03:00
OrmTestCase.php Optimize imports. Remove full qualified class names 2016-05-11 01:55:12 +07:00
TestInit.php [DDC-3461] Renamed AssocationBuilder::isPrimaryKey() to makePrimaryKey(). Same for FieldBuilder and depreceating isPrimaryKey(). Adjust tests. Revert change in ClassMetadataInfo and fix bug. 2015-03-18 17:06:30 +01:00
TestUtil.php Updated syntax for ``integer` and `boolean`` types 2015-07-14 15:30:13 -03:00