#88613Replace ObjectStorage & LazyObjectStorage with symfony/collection
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
Related issues 2
History 1114
-
Gerrit Code Review pushed patch set 1 for master to change 61118 status
NewUnder Review <span data-processor="relativetime" data-value="2019-06-21T21:44:56+00:00" > 06/21/19, 21:44 </span> -
Gerrit Code Review pushed patch set 2 for master to change 61118 <span data-processor="relativetime" data-value="2019-06-22T07:20:41+00:00" > 06/22/19, 07:20 </span>
-
Gerrit Code Review pushed patch set 3 for master to change 61118 <span data-processor="relativetime" data-value="2019-06-24T08:55:41+00:00" > 06/24/19, 08:55 </span>
-
Oliver Hader changed description <span data-processor="relativetime" data-value="2019-07-15T13:54:41+00:00" > 07/15/19, 13:54 </span>
-
Oliver Hader changed subject
Properly deny serialization of Extbase object storageSubstitute ObjectStorage & LazyObjectStorage with symfony/collection statusUnder ReviewAccepted <span data-processor="relativetime" data-value="2019-07-15T13:58:53+00:00" > 07/15/19, 13:58 </span> -
Oliver Hader changed subject
Substitute ObjectStorage & LazyObjectStorage with symfony/collectionReplace ObjectStorage & LazyObjectStorage with symfony/collection <span data-processor="relativetime" data-value="2019-07-15T13:59:19+00:00" > 07/15/19, 13:59 </span> -
Alexander Schnitzler commented and changed priority
Should haveWon'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.
-
Oliver Hader changed Related to #91387 <span data-processor="relativetime" data-value="2020-05-14T12:56:21+00:00" > 05/14/20, 12:56 </span>
-
Christian Kuhn commented and changed status
AcceptedClosed <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. -
Oliver Hader commented and changed status
ClosedNew priorityWon't have this timeShould 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.
-
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.
-
Benni Mack changed Related to #110347 <span data-processor="relativetime" data-value="2026-07-31T19:03:57+00:00" > 07/31/26, 19:03 </span>
-
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.
@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.