1
0
mirror of synced 2025-02-02 13:31:45 +03:00
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
2013-12-16 11:05:05 -05:00
2014-03-01 17:13:28 -05:00
2013-03-07 14:12:10 +01:00
2013-09-07 12:56:49 +02:00
2013-09-07 12:56:49 +02:00
2013-12-14 11:29:07 +01:00
2012-05-26 14:37:00 +02:00
2013-03-11 00:08:58 +00:00
2015-01-25 23:54:59 +01:00
2013-03-11 00:08:58 +00:00

Master 2.4 2.3 2.2 2.1
Build status Build status Build status Build status Build status
Coverage Status

Doctrine 2 is an object-relational mapper (ORM) for PHP 5.4+ that provides transparent persistence for PHP objects. It sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernate's HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.

More resources:

Description
Doctrine 2 Object Relational Mapper (ORM)
Readme MIT 32 MiB
Languages
PHP 100%