1
0
Fork 0
mirror of synced 2025-04-01 20:36:14 +03:00
doctrine2/tests/Doctrine/Tests/ORM
Mathieu De Zutter 95dcf51ad5 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-10 20:16:28 +02:00
..
Cache Evict query cache when entities are updated 2016-09-08 13:56:46 +02:00
Decorator Adding EntityManagerDecorator base class as an extension point for EntityManager 2013-03-06 23:30:47 +01:00
Entity Removed all useless occurrence of require_once TestInit.php 2014-04-07 14:43:25 +02:00
Event #385 #1181 DDC-3385 - test coverage for OnClassMetadataNotFoundEventArgs impl 2015-01-13 21:04:50 +01:00
Functional Avoid conflicts due to spl_object_hash(). 2016-09-10 20:16:28 +02:00
Hydration Add unit test for SimpleObjectHydrator 2016-09-08 13:38:34 +02:00
Id Removed all useless occurrence of require_once TestInit.php 2014-04-07 14:43:25 +02:00
Internal #1001 DDC-3005 - Verifying HydrationCompleteHandler skips over registered deferred loads that were already handled by hydrationComplete 2015-01-13 00:48:53 +01:00
Mapping Removed annotation reader constructor argument (incorrect argument used) 2016-06-06 01:34:20 +02:00
Performance Classify persisters into more granular namespaces. 2015-01-16 00:10:25 +01:00
Persisters Tested composite primary key support 2015-02-16 00:53:46 +00:00
Proxy Classify persisters into more granular namespaces. 2015-01-16 00:10:25 +01:00
Query Regression test: HAVING clause does not translate variable name when used with * and / math operators 2016-01-16 10:28:43 -06:00
Repository #1159 - EOF EOL CS fixes for Doctrine\ORM\Repository\DefaultRepositoryFactory tests 2014-10-14 01:49:57 +02:00
Tools Exporters should only inspect joinColumns for owning side in bi-directional OneToOne 2016-06-08 13:34:10 +02:00
Utility Refactored IdentifierFlattener 2015-02-16 00:53:46 +00:00
CommitOrderCalculatorTest.php Removed all useless occurrence of require_once TestInit.php 2014-04-07 14:43:25 +02:00
ConfigurationTest.php Ensure query cache is not ArrayCache in production 2014-12-19 20:18:45 +01:00
EntityManagerTest.php #1172 - reverted: moving MergeUninitializedProxyTest tests into EntityManagerTest (invalid, as they are functional tests) 2015-01-16 22:43:03 +01:00
EntityNotFoundExceptionTest.php #1240 DDC-3479 - Basic coverage for EntityNotFoundException 2015-01-13 02:55:51 +01:00
LazyCriteriaCollectionTest.php Classify persisters into more granular namespaces. 2015-01-16 00:10:25 +01:00
PersistentCollectionTest.php Removing irrelevant tests (as per discussion with @guilhermeblanco and @stof 2015-04-05 01:29:42 +01:00
QueryBuilderTest.php Merge pull request #1303 from mrkrstphr/querybuilder-get-all-aliases 2015-03-17 23:33:43 +00:00
UnitOfWorkTest.php Removed reliance on ::class meta-constant (only available in PHP 5.5+) 2016-06-06 01:48:32 +02:00