Bug #13559

ObjectSerializer failes with persistent objects within arrays

Added by Martin Eisengardt over 10 years ago. Updated over 8 years ago.

Status:
Accepted
Priority:
Should have
Category:
Persistence
Target version:
-
Start date:
2011-03-02
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

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

Actions
#2

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?

#3

Updated by Karsten Dambekalns over 8 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