1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00
Doctrine 2 Object Relational Mapper (ORM)
Find a file
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
bin Fix the composer autoload paths for the doctrine CLT 2014-07-24 09:52:55 -04:00
docs Backport Merge pull request #1430 from michael-lavaveshkul/master 2015-06-18 10:41:56 -04:00
lib Avoid conflicts due to spl_object_hash(). 2016-09-10 20:16:28 +02:00
tests Avoid conflicts due to spl_object_hash(). 2016-09-10 20:16:28 +02:00
tools/sandbox Region cache clear commands 2013-12-16 11:05:05 -05:00
.coveralls.yml Simplify build matrix 2014-03-01 17:13:28 -05:00
.gitattributes Remove README.markdown from .gitattributes 2013-01-19 20:04:43 +01:00
.gitignore Added composer.lock to .gitignore 2013-03-07 14:12:10 +01:00
.gitmodules Removing submodules as of doctrine/doctrine2#570 2013-02-15 18:33:29 +01:00
.travis.yml Removing coveralls installation/reporting from 2.5: not required 2016-01-05 22:25:57 +01:00
build.properties New Build process 2013-09-07 12:56:49 +02:00
build.properties.dev Add support to distribute the XSD to a given directory during build process 2011-08-27 13:23:17 +02:00
build.xml New Build process 2013-09-07 12:56:49 +02:00
composer.json Removing coveralls installation/reporting from 2.5: not required 2016-01-05 22:25:57 +01:00
CONTRIBUTING.md Update CONTRIBUTING.md 2013-12-14 11:29:07 +01:00
doctrine-mapping.xsd Adding use-column-prefix attribute as proposed (DDC-3293) #1239 2015-01-08 00:09:30 -02:00
LICENSE LGPL => MIT 2012-05-26 14:37:00 +02:00
phpunit.xml.dist Fixed typos 2013-03-11 00:08:58 +00:00
README.markdown Typo fix 2015-01-25 23:54:59 +01:00
run-all.sh Fixed typos 2013-03-11 00:08:58 +00:00
SECURITY.md Add SECURITY.md and a chapter on security assumptions in Doctrine ORM. 2014-02-21 16:12:32 +01:00
UPGRADE.md #6001 documenting minor BC break in QueryCacheEntry#time type - specific version used 2016-09-08 13:58:30 +02: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: