http://www.doctrine-project.org/jira/browse/DDC-3619
When using SoftDeleteable doctrine extension, an entity can be scheduled
for deletion, then persisted before flushing. In such a case, the entity
was removed from the unit of work identity map and no reference was
hold. This could lead to spl_object_hash collisions, and prevent
another, new entity to be persisted later.
This fix makes sure the unit of work identity map holds a reference to
the entity after it has been soft-deleted.
Possibly to do:
1. Make custom Exception for line 713
2. Make custom Exception for line 817
3. Does the object check on line 816 slow down the code too much? Alternatively a try-catch could be put around line 1415 or higher up.
Previous patch avoided initialization of proxies before merging, mainly to
fix a bug with merging. However, later on, doctrine tries again to load
the proxy. This is unnecessary and thus has been removed. This way, a
round trip to the database is saved.
Ticket DDC-1392 fixed an issue where uninitialized proxies could not be merged
because the merge routine couldn't get the identifier from them. The soution
was to initialize the proxy.
Ticket DDC-1734 fixed the merging of *unserialized* uninitialized proxies by
resetting their internals, so these proxies were able to initialize, as required
by the fix for DDC-1392.
Somehow, in the meanwhile, the fix for DDC-1392 is not needed anymore:
reverting the patch will not break the associated test (but it does break the
test for DDC-1734). This means it is not needed anymore to initialize the proxy
when merging.
Uninitialized proxies that get merged should not be loaded at all. Since they
are not initialized, the entity data for sure hasn't changed, so it can be
safely ignored. Actually, the only thing the data is needed for while merging,
is to copy it into the managed entity, but that one is already supposed to be
up to date. By not initializing the proxy, a potential database roundtrip is
saved, and the fix for DDC-1734 is not needed anymore.
Besides optimizing the merge, this patch also solves an issue with merging.
Currently, when a detached uninitialized proxy is merged while there is already a
corresponding managed entity (proxy or not), the ORM returns a blank entity
instead of returning the already managed entity. This patch makes sure that
already existing managed entities are re-used.
1. Refactor handling of hydration complete: delegate this task to special object
2. Write test case for situation, when inside postLoad listener other entity is loading.
3. Make test, written on second step, be able to pass :)
Without this patch, when an entity that refers multiple times to the same
associated entity gets merged, the second references becomes null.
The main issue is that even though doMerge returns a managed copy, that value
is not used while cascading the merge. These identicial entities are already
detected through the visitor map, but they are ignored. There should be some
refactoring so cascadeMerge calls a function that checks if the parent must be
updated, based on the return value of its call to doMerge. However, this patch
tries to impact the code as little as possible, and only introduces a new
function to avoid duplicate code.
The secondary issue arises when using inverted associations. In that case, it
is possible that an entity to be merged is already merged, so the the visitor
map is looked up by the hash of a managed copy instead of the original entity.
This means that in this case the visitor map entries should also be set to the
entity, instead of being set to 'true'.
- Created an IdentifierFlattener utility class
- Moved the logic for the flatten identifier method into the new utility class
- Replaced calls for private flattenIdentifier to use new utility
- Added appropriate unit tests
A fix for DDC-2996 was implemented that broke quite a few extensions.
This commit is an attempt to fix the DDC-2996 bug without the adverse side effects seen in DDC-3160.
Basically, if changes are detected that would cause a changeset to be made, but the entity is awaiting insertion, the code will not save the changeset nor flag the entity as awaiting updating in the Unit of Work.
Some styling tweaks based on Pull Request guidelines.
When calling UnitOfWork#recomputeSingleEntityChangeSet on an entity
that didn't have a changeset before, the computation was ignored.
This method however is suggested to be used in "onFlush" and "preFlush"
events in the documentation.
Also fix a bug where recomputeSingleEntityChangeSet was used
before calculating a real changeset for an object.
The fix for DDC-2624 had a side effect on recomputation of
changesets in preUpdate events. The method wasn't adjusted
to the changes in its sister method computeChangeSet() and
had wrong assumptions about the computation.
Especially:
1. Collections have to be skipped
2. Comparison was changed to strict equality only.