Bug #11893

The hash identifying a ValueObject isn't sufficient

Added by Jochen Rau over 10 years ago. Updated about 10 years ago.

Status:
Resolved
Priority:
Should have
Category:
Persistence
Start date:
2011-01-05
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

After executing the constructor of a Value Object a hash is generated and stored in FLOW3_Persistence_ValueObject_Hash to identify the Value Object (eg. to support getIdentifierByObject($object)). But the algorithm for generating the hash isn't sufficient for some cases.

Let's assume we have a Value Object \F3\MyExt\Domain\Model\Color with a property $colorNumber=42. This Value Object has the same hash as a Value Object \F3\MyExt\Domain\Model\Length with a property $value=42. The same problem occurs, if a Value Object stores other objects in an SplObjectStorage or uses PHP classes like DateTime.

IMHO the identity of a ValueObject is fully determined only by taking all property values (including SplObjectStorages) and the class into account. The test for FLOW3_Persistence_Entity_UUID could possibly be dropped as a Value Object by definition can't reference to Entities.

Also available in: Atom PDF