Review main Merged

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

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

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
    • Garvin Hicking +1
    • Jan Kornblum +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Oliver Klee +1
    • Garvin Hicking +1
    • Jan Kornblum +1
    • core-ci +1 CI

Issues 1

Files 13

Review log 1719

  1. Garvin Hicking uploaded patch set 1 07/16/26, 10:17

  2. Garvin Hicking commented on patch set 1 07/16/26, 10:21

    (See https://review.typo3.org/c/Packages/TYPO3.CMS/+/91004 for another stab at this, which I only discovered due to the possible merge conflict with it)
  3. core-ci voted on patch set 1 V +1 07/16/26, 10:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104828

  4. Jan Kornblum commented on patch set 1 CR +1 V +1 07/16/26, 14:02

    It works fine for me.
  5. Oliver Klee voted on patch set 1 V +1 07/16/26, 21:05

  6. Benni Mack commented on patch set 1 07/17/26, 07:17

    ColumnMapFactory.php:137

    tbh, I don't know if we should consider the "Tx_Foo_Bar" edge-case
  7. Garvin Hicking commented on patch set 1 07/17/26, 08:23

    ColumnMapFactory.php:137 Reply

    Did not fully check what it does. Could also be a "txsometable:4711" identity resolving?
  8. Benni Mack commented on patch set 1 CR +1 09/01/26, 12:51

    ColumnMapFactory.php:137 Reply

    Done
  9. Stefan Bürk commented on patch set 1 CR -2 09/01/26, 12:53

    Need to check something ...
  10. Stefan Bürk uploaded patch set 2 CR +1 V +1 09/02/26, 20:14

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  11. core-ci voted on patch set 2 V +1 09/02/26, 20:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107675

  12. Stefan Bürk commented on patch set 2 CR +1 V +1 09/02/26, 20:41

    Reply

    I thought to combine that with my original approach coming from another angle (abandoned: 91004: [WIP][BUGFIX] Avoid assuming custom property type is a relation | https://review.typo3.org/c/Packages/TYPO3.CMS/+/91004) and based on the test and this approach reinvestaged the whole place. The strpbrk, as acient as it was and pushed around over time, was the "object" check for class/type properties to decide for the handling from a really really long time ago; pushed around, survived refactorings, moved again - no one touched it and my best guess is that no-one really understood the origin or the reason for it - something which come clear now. Putting all the pieces together we can a) get rid of that acient check and pattern not understood without looking long on that place, b) solve the enum and single object (CoreType, ValueObject) pattern not describing a relation in any form in one go with a simplification of the check making it more clearer for the modern days. The test coverage was already really helpfull for that, I slightly rearranged it to add tests for the other/my cases also to the chain, hopefully making that even more visible. I think that the new approach evolved from all the investigation is a really good way to go here and I'm hoping that other sees it the same way. Leaving the comment open to raise awareness, can be simply resolved when change is okay and is the final reason to block the change from being merged.
  13. Garvin Hicking commented on patch set 2 CR +1 V +1 09/03/26, 06:18

    Reply

    Thanks! That looks great. I alao looked sone more into this legacy notation and I feel confident it really is like you outlined. Resolving this.
  14. Oliver Klee voted on patch set 2 V +1 09/03/26, 06:50

  15. Jan Kornblum voted on patch set 2 CR +1 09/03/26, 15:38

  16. Jan Kornblum voted on patch set 2 V +1 09/03/26, 15:38

  17. Stefan Bürk commented on patch set 2 CR -1 V +2 09/03/26, 17:28

    Taking care of the backports before merging.
  18. Stefan Bürk voted on patch set 2 CR +2 09/03/26, 22:42

  19. Stefan Bürk merged patch set 3 09/03/26, 22:42