Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress Quiet Breaking

96533[WIP][!!!][TASK] Build Extbase persistence on doctrine/orm

Alexander Schnitzler CR 0 V -1 Impossible +10608 −1999 updated 10/08/26, 12:53

Commit message

Proof of concept, not meant to be merged: it shows what has to change
to make doctrine/orm the persistence core of Extbase while keeping the
Extbase query API and TYPO3's language and workspace overlays.

Doctrine owns identity map, change sets, commit order and lazy
collections. Extbase keeps building and executing its queries; the
overlaid rows are hydrated into Doctrine entities.

- Preparation: the query parser is split into predicate builders, the
  frontend/backend decision moves into the query settings, the row
  overlay becomes a service and the write targets are resolved in one
  place.
- Tests pin the behaviour before the rebuild: language and workspace
  overlays, write targets, relation writes, record types, value
  objects, events, and lazy loading and identity as numbers of queries.
- An EntityManager service, built lazily on the default connection.
  Metadata comes from TCA and the Extbase class schema. Change tracking
  is deferred explicit, so only objects handed to add() and update()
  are persisted, with their graph.
- The identity of an entity is the uid of the physically selected row,
  the translation's uid in a translated context; getUid() keeps the
  default-language uid.
- To-many properties are Doctrine collections instead of ObjectStorage.
- Entity and collection persisters are replaced through the
  second-level-cache factory, the only hook Doctrine offers. They load
  through Extbase queries and write TYPO3 rows themselves: storage pid,
  language fields, crdate/tstamp, soft delete, reference index, inline,
  MM and comma-list relations, value object reuse and the persistence
  events.
- Lazy to-one relations are Doctrine lazy objects where the stored uid
  is the target's identity and are loaded eagerly where they resolve in
  a translation. Already loaded to-one targets are reused without a
  query where the uid is known.
- The write code of the Extbase backend, the session identity keys and
  the old dirty tracking are gone or no longer authoritative.
- EXT:beuser and the IRRE test fixtures use collections.

Tests whose subject no longer exists are skipped with the reason.
Tests whose expectation changed carry the new expectation and the old
one in a comment. Breaking changes are listed as changelog files.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/33/96533/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/33/96533/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V -1 Blocked
    • core-ci -1 CI

Issues 1

Files 131

Show 111 more files

Review log 35

  1. Alexander Schnitzler uploaded patch set 1 10/08/26, 12:18

  2. core-ci voted on patch set 1 V -1 10/08/26, 12:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110488

  3. Alexander Schnitzler uploaded patch set 2 V -1 10/08/26, 12:39

  4. Alexander Schnitzler commented on patch set 2 10/08/26, 12:41

    The two failing tests are expected. ObservablePersistenceBehaviourTest::lazyUidToOneToTranslatableTargetInLanguageOneIsQueriedOnFirstAccessOnly (data sets on and mixed) pins today's Extbase behaviour. In language 1, a #[Lazy] to-one relation to a translatable record is not queried until its state is first accessed. In this PoC the relation is loaded eagerly in that case, so the test sees one query too many at load time. This is a known, accepted limitation, not a bug: - Why it happens: The Doctrine identity of an entity is the uid of the physically loaded row, which for a translation is the translation's uid. A Doctrine lazy object must be registered under its identity before it is loaded. For a translated target that uid is only known after the language overlay has run, so no lazy object can be created up front. - Where lazy loading still works: In the default language, in workspaces and for non-translatable targets, lazy to-one relations are real Doctrine lazy objects. - Why today's Extbase does not have this problem: It uses a native lazy proxy (newLazyProxy()) that creates the real object only after the overlay. Details: Breaking-110965-LazyToOneRelationsLoadedEagerly.rst
  5. core-ci voted on patch set 2 V -1 10/08/26, 12:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110491