Review 13.4 Merged

95608[BUGFIX] Do not map value types as Extbase relations

Garvin Hicking CR +2 V +2 Hard +641 −3 updated 09/03/26, 22:43

Commit message

Extbase detected a to-one relation for every model property
typed with a class, based on a class-name heuristic
(`strpbrk($propertyType, '_\\')`) in ColumnMapFactory that
dates back to the non-namespaced "Tx_Extension_..." era.

That classifies properties typed with a backed enum or with a
custom `TypeInterface` value object (for example a JSON
decoding type on a `type=json` or `type=text` column) as
`Relation::HAS_ONE`, although they are persisted inline as
scalar values and have no target table.

`Backend::insertObject()` unconditionally writes 0 into every
`HAS_ONE` column on INSERT. A property holding a value is
dirty and gets corrected by the follow-up UPDATE, but a
nullable property left as null is never dirty, so the 0 from
the INSERT survives: A nullable enum is stored as 0 instead
of NULL, and a nullable value object is stored as 0, which
cannot be mapped back into the type on reconstitution. A
plain nullable scalar (`?int`) is correctly stored as NULL.

The heuristic is replaced by checking whether the property
type is a `DomainObjectInterface`. This is the discriminator
`Backend::getPlainValue()` already uses to decide whether a
null value is persisted as 0 (domain object) or as NULL, so
column map creation and persistence now agree. Entities on
non-relational TCA columns (e.g. `passthrough`) keep their
`HAS_ONE` mapping.

Tests cover the relation detection for enum and core type
properties on number, select, passthrough, json and text
columns, and the persistence round trip (INSERT value, NULL
handling and reconstitution) for a nullable backed enum and
for a `TypeInterface` JSON value object.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
  • Verified V +2 Done
    • Stefan Bürk +2
    • core-ci +1 CI

Issues 1

Files 17

Review log 69

  1. Garvin Hicking commented on patch set 1 09/03/26, 16:44

    Cherry Picked from branch main. The following files contain Git conflicts: * typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/ColumnMapFactory.php * typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/test_json_fields/Classes/Domain/Model/Example.php * typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/test_json_fields/Configuration/TCA/tx_testjsonfields_domain_model_example.php
  2. Garvin Hicking commented on patch set 2 09/03/26, 16:49

    Published edit on patch set 1.
  3. core-ci voted on patch set 2 V -1 09/03/26, 17:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107765

  4. core-ci voted on patch set 1 V -1 09/03/26, 17:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107764

  5. Stefan Bürk marked it ready for review 09/03/26, 20:27

  6. Stefan Bürk uploaded patch set 3 V -1 09/03/26, 20:32

  7. core-ci voted on patch set 3 V +1 09/03/26, 20:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107782

  8. Stefan Bürk voted on patch set 3 CR +2 V +2 09/03/26, 22:42

  9. Stefan Bürk merged patch set 4 09/03/26, 22:43