[DDC-688] Original Entity Data gets overridden by the change set Created: 12/Jul/10  Updated: 28/Dec/10

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0-BETA2
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Jasper Kuperus Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Mac OS X 10.6; PHP 5.3.2; MySQL 5.1.44



 Description   

When changing data in an entity, the UnitOfWork will call computeChangeSet on a flush event. If there is a changeset, the original data ($this->_originalEntityData) gets overridden by the new data. However, the _originalEntityData should hold the original data, that was present at the time the entity was reconstituted from the database. This does no longer hold now.

I think this can simply be fixed by commenting this line, however I do not know of any consequences this may bring with it:

$this->_originalEntityData[$oid] = $actualData; (in computeChangeSet, after if( $changeSet ));

Anyway, I ran into this problem while trying to retrieve the original data at the onFlush event of an update.



 Comments   
Comment by Roman S. Borschel [ 08/Aug/10 ]

This is actually currently expected. You can not get access to the original data in the onFlush event right now. I'm not saying that this will never be possible but it is simply the way it works at the moment.

Comment by Jasper Kuperus [ 08/Dec/10 ]

Does this mean that it is currently impossible to implement a Versionable mechanism using snapshots?

Comment by Benjamin Eberlei [ 09/Dec/10 ]

You can hold a map of them yourself if your listener also implements the "postLoad" event:

$entity = $args->getentity();
$this->originalData[spl_object_hash($entity)] = $args->getEntityManager()->getUnitOfWork()->getOriginalData($entity);
Comment by Benjamin Eberlei [ 28/Dec/10 ]

Changed into possible improvement for the future

Generated at Fri Jul 25 22:18:03 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.