Bug #13559

ObjectSerializer failes with persistent objects within arrays

Added by Martin Eisengardt over 10 years ago. Updated almost 9 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Has patch:


If a persistent object is contained in an array property, the serialization failes. It won't detect the object as persistent but will persist it as if it was a simple data object. This will be broken as soon as the session is resumed/ the object serializer is unserializing this data stream.

The reason is that persistent object detection is only present in method serializeObjectAsPropertyArray. Method buildStorageArrayForArrayProperty only contains a small is_object that won't respect the persistence:

if (is_object($value)) {
                $storableArray[$key][self::TYPE] = 'object';
                $storableArray[$key][self::VALUE] = spl_object_hash($value);

                $this->serializeObjectAsPropertyArray($value, FALSE);

Related issues

Related to TYPO3.Flow - Bug #42715: ObjectSerializer not capable of CollectionsResolvedKarsten Dambekalns2012-11-06


Updated by Christian Müller over 9 years ago

  • Status changed from New to Needs Feedback
  • Has patch set to No

Persistable Objects should best be stored in a Doctrine Collection like the ArrayCollection. Then persistence will persist the objects properly. Do we still want to fix this somehow?


Updated by Karsten Dambekalns almost 9 years ago

  • Category set to Persistence
  • Status changed from Needs Feedback to Accepted
  • Assignee set to Karsten Dambekalns

Possible without too much hassle.

Also available in: Atom PDF