doctrine/common — pull request #340 by liutec (2014-10-21 14:43:37+00:00)
Title: Change tracking interface for object values

Currently, aside from the "NOTIFY" change tracking policy which takes long to implement on pre-existing entities, there is no atomic mechanism to allow tracking changes that take place inside de-serialized values of the DBAL\ObjectType once the entity has been loaded.

The UnitOfWork uses PHP's identity comparison operator (===) to compute the changed sets which yelds no change result when comparing pointers to the same object instance.

By implementing this interface, a serialized object may manage it's own dirty state and ensure the new values are persisted without affecting the entity's current change tracking policy.

The corresponding pull request on doctrine2 changes the following in Doctrine\ORM\UnitOfWork.php:
// skip if value haven't changed
if ($orgValue === $actualValue) {
continue;
}

into:

// skip if value haven't changed
if (($orgValue === $actualValue) && ( ! ($actualValue instanceof ObjectChangeTracking) || ( ! $actualValue->isDirty()))) {
continue;
}