Review main Merged

95039[FEATURE] Use native PHP lazy objects for Extbase lazy loading

Benni Mack CR +2 V +2 Hard +622 −57 updated 09/02/26, 05:06

Commit message

Relations of domain model properties annotated with #[Extbase\ORM\Lazy]
are now created as native PHP lazy objects by the DataMapper:

* 1:n and m:n relations as lazy ghost instances of the regular
  ObjectStorage class
* 1:1 and n:1 relations as lazy proxy instances of the actual target
  entity class, with the uid of the related record available on the
  uninitialized proxy without database access

A lazy relation therefore is a real instance of its target type:
instanceof checks work, native property types can be used for lazy
properties, and manual _loadRealInstance() unwrapping in getters is
obsolete. The previously used proxy classes LazyLoadingProxy,
LazyObjectStorage and their LoadingStrategyInterface have been marked
as deprecated and are no longer used by TYPO3 Core.

ObjectStorage and AbstractDomainObject now implement __serialize() and
__unserialize(): A lazy object is explicitly initialized before its
state is collected, since the PHP engine's serializer must never
trigger the initialization of a lazy object during its traversal, as
that corrupts back references within the serialized payload.
ObjectStorage rebuilds its spl_object_hash() based bookkeeping on
unserialize(), so detach(), contains() and offsetGet() now work
correctly on unserialized storages.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Andreas Kienast +1
    • Matthias Vogel +1
  • Verified V +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Oliver Klee +1
    • Matthias Vogel +1
    • core-ci +1 CI

Issues 1

Files 27

Show 7 more files

Review log 1316

  1. Benni Mack uploaded patch set 1 07/31/26, 18:08

  2. core-ci voted on patch set 1 V +1 07/31/26, 18:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105757

  3. Benni Mack marked it ready for review 08/06/26, 18:24

  4. Andreas Kienast commented on patch set 1 08/06/26, 20:05

    ObjectStorage.php:393

    What's the deal with this condition? Is this obsolete debugging / test code?
  5. Oliver Klee voted on patch set 1 V +1 08/06/26, 21:57

  6. Matthias Vogel uploaded patch set 2 V +1 08/26/26, 07:19

  7. Matthias Vogel commented on patch set 2 08/26/26, 07:21

    ObjectStorage.php:393 Reply

    This is the "warning" text from the top of the class (line 43).
  8. core-ci voted on patch set 2 V -1 08/26/26, 07:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107123

  9. Matthias Vogel uploaded patch set 3 V -1 08/26/26, 07:42

  10. core-ci voted on patch set 3 V +1 08/26/26, 07:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107126

  11. Matthias Vogel voted on patch set 3 CR +1 V +1 08/26/26, 08:03

  12. Oliver Klee voted on patch set 3 V +1 08/26/26, 11:05

  13. Andreas Kienast voted on patch set 3 CR +1 08/26/26, 11:51

  14. Georg Ringer voted on patch set 3 CR +1 V +1 09/01/26, 20:30

  15. Benni Mack voted on patch set 3 CR +2 V +2 09/02/26, 05:06

  16. Benni Mack merged patch set 4 09/02/26, 05:06