Issue Bug New Quiet

#88613Replace ObjectStorage & LazyObjectStorage with symfony/collection

Oliver Hader 06/21/19, 21:37 updated 10/17/26, 13:42

Description

For regular ObjectStorage deserialization most probably would work – however there are inconsitencies concerning object integrity due to ObjectStorage using spl_object_hash() internally. In a result it would not be possible to detach an object retrieved from repository from some deserialized ObjectStorage – basically uid should be used as identifier here which would turn ObjectStorage into EntityStorage. So, we could live with serialization of ObjectStorage.

For LazyObjectStorage things are getting more difficult since serialization of it would mean to serialize backreferences to parent object as well as DataMapper state, ObjectManager state and in the end class Reflection state – that turns out to be a massive collection of serialized data.

Thus, we experience most pain with LazyObjectStorage and its current implementation.

Reviews 2

History 1114

  1. Gerrit Code Review pushed patch set 1 for master to change 61118 status New Under Review <span data-processor="relativetime" data-value="2019-06-21T21:44:56+00:00" > 06/21/19, 21:44 </span>

  2. Oliver Hader commented <span data-processor="relativetime" data-value="2019-07-15T13:55:59+00:00" > 07/15/19, 13:55 </span>

    @Alexander Schnitzler (https://review.typo3.org/c/Packages/TYPO3.CMS/+/61118/3#message-e5ec8c4a56d55a65395753969b7d240c8effc6cb)

    > I am planning to replace our ObjectStorage with doctrine/collection anyway. That also means, that our Lazy-Objects won’t be used any more. The Collection also doesn’t have any services injected, its state is handled from the outside. So, if we don’t have issues with people trying to serialize their object storages at the moment, I’d say, let’s abandon this patch and work on a better implementation.

  3. Oliver Hader changed subject Properly deny serialization of Extbase object storage Substitute ObjectStorage & LazyObjectStorage with symfony/collection status Under Review Accepted <span data-processor="relativetime" data-value="2019-07-15T13:58:53+00:00" > 07/15/19, 13:58 </span>

  4. Oliver Hader changed subject Substitute ObjectStorage & LazyObjectStorage with symfony/collection Replace ObjectStorage & LazyObjectStorage with symfony/collection <span data-processor="relativetime" data-value="2019-07-15T13:59:19+00:00" > 07/15/19, 13:59 </span>

  5. Alexander Schnitzler commented and changed priority Should have Won't have this time <span data-processor="relativetime" data-value="2020-02-25T15:11:40+00:00" > 02/25/20, 15:11 </span>

    This will not make it into 10. The change is quite invasive as it forces users to touch their code. The mere inner representation of collections is not so much the issue but at the moment, ObjectStorage’s are very exposed in the public api. They are even used as identifier in annotations and therefore pretty much bind the concrete class to the user land code.

  6. Christian Kuhn commented and changed status Accepted Closed <span data-processor="relativetime" data-value="2023-01-06T12:20:26+00:00" > 01/06/23, 12:20 </span>

    Hey.
    I hope it’s ok to close here for now: The initial patch has been abandoned and nothing happened for some years.
    I hope it’s fair to create a fresh issue in case work is continued here.

  7. Oliver Hader commented and changed status Closed New priority Won't have this time Should have <span data-processor="relativetime" data-value="2023-01-09T07:17:34+00:00" > 01/09/23, 07:17 </span>

    Hey, I hope it’s okay to reopen this issue again, since the pain points of the lazy object storage still seem to be existing and this issue provided a potential path to solve it.

  8. Benni Mack commented <span data-processor="relativetime" data-value="2026-07-31T19:03:52+00:00" > 07/31/26, 19:03 </span>

    The main pain point discussed here — LazyObjectStorage and LazyLoadingProxy with their serialization problems — is now resolved for TYPO3 v15 via #110347: Extbase uses native PHP lazy objects (PHP 8.4+) for lazy relations.

    This also addresses the serialization issues from the description: lazy relations no longer serialize backreferences to the parent object or DataMapper state, and ObjectStorage now rebuilds its spl_object_hash() based bookkeeping in __unserialize(), so detach()/contains() work on unserialized storages — the object integrity problem mentioned above.

    Fun fact: while implementing this we found a PHP engine bug — serialize() doesn’t unify a lazy proxy with its real instance, which corrupts object graphs: https://github.com/php/php-src/issues/22979

    What remains of this issue is the second part: whether ObjectStorage itself should move towards a collection API. symfony/collection never materialized as a package, so doctrine/collections would be the candidate today — mainly interesting if we also implement Criteria/Selectable pushdown to the persistence layer. I’d suggest handling that in a fresh issue if someone picks it up, and closing this one once #110347 is merged.

  9. Alexander Schnitzler commented <span data-processor="relativetime" data-value="2026-10-17T13:42:43+00:00" > 10/17/26, 13:42 </span>

    +1 for aiming towards doctrine/orm and their collection interface here. https://review.typo3.org/c/Packages/TYPO3.CMS/+/96533 proofs that it’s doable.