Review main Ready for review Quiet

93782[FEATURE] Handle MM relations in SaveToDatabase finisher

Josua Vogel CR -2 V 0 Expert +1525 −63 updated 10/07/26, 14:45

Commit message

The SaveToDatabase finisher now handles MM relations when the mapped
database column is configured as an MM relation in TCA.

The finisher reads the MM table name, match fields, sorting and
opposite field handling directly from TCA and delegates the writing
of the relation records to the RelationHandler. The mapped column
receives the relation count, the individual relations are written to
the MM table.

In insert mode the MM records reference the newly inserted record.
In update mode existing relations are synchronized (added, re-sorted
and obsolete relations removed), which requires a "uid" in the
whereClause that matches an existing record.

Submitted form values are unvalidated user input, so only positive
integers are accepted as relation targets, and the relation must
point to a single table defined in TCA. Group fields allowing "*" or
several tables are rejected, since the submitted value would
otherwise pick the table the relation points to.

The record and its MM records are written in one transaction, the
reference index is updated afterwards, and relations are always
written in the live workspace.

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 23
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/82/93782/23 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/82/93782/23 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -2 Blocked
    • Stefan Bürk -2
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Issues 1

Files 9

Review log 4264

Show 2539 earlier messages
  1. Josua Vogel uploaded patch set 1 04/21/26, 14:29

  2. Josua Vogel uploaded patch set 2 04/21/26, 14:56

  3. Josua Vogel uploaded patch set 3 04/21/26, 15:00

  4. Josua Vogel commented on patch set 4 04/21/26, 15:03

    Published edit on patch set 3.
  5. core-ci voted on patch set 1 V -1 04/21/26, 15:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100647

  6. core-ci voted on patch set 2 V -1 04/21/26, 15:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100656

  7. core-ci voted on patch set 3 V -1 04/21/26, 15:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100658

  8. core-ci voted on patch set 4 V -1 04/21/26, 15:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100659

  9. Josua Vogel rebased onto patch set 5 V -1 04/22/26, 05:44

  10. core-ci voted on patch set 5 V -1 04/22/26, 06:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100685

  11. Benni Mack updated the commit message in patch set 6 V -1 04/22/26, 07:23

  12. Josua Vogel uploaded patch set 7 04/22/26, 11:02

  13. core-ci voted on patch set 7 V -1 04/22/26, 12:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100893

  14. Josua Vogel uploaded patch set 8 V -1 04/22/26, 12:26

  15. core-ci voted on patch set 8 V +1 04/22/26, 12:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100896

  16. Josua Vogel rebased onto patch set 9 V +1 04/22/26, 14:46

  17. core-ci voted on patch set 9 V +1 04/22/26, 15:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100911

  18. Josua Vogel rebased onto patch set 10 V +1 04/23/26, 18:21

  19. core-ci voted on patch set 10 V +1 04/23/26, 18:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/101054

  20. Josua Vogel uploaded patch set 11 V +1 05/05/26, 15:37

  21. core-ci voted on patch set 11 V +1 05/05/26, 15:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/101565

  22. Josua Vogel rebased onto patch set 12 V +1 05/22/26, 07:55

  23. core-ci voted on patch set 12 V +1 05/22/26, 08:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102349

  24. Oliver Klee voted on patch set 12 V +1 05/29/26, 07:00

  25. Josua Vogel rebased onto patch set 13 V +1 07/24/26, 14:46

  26. core-ci voted on patch set 13 V +1 07/24/26, 14:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105333

  27. Oliver Klee voted on patch set 13 V +1 07/24/26, 15:03

  28. Benni Mack commented on patch set 13 CR -1 07/24/26, 15:16

    how about using RelationHandler ?
  29. Garvin Hicking commented on patch set 13 07/24/26, 15:18

    SaveToDatabaseFinisher.php:284

    I would prefer passing $elementValue to the method above and then passing the whole return object to the pendingMmRelations to it. And I'd prefer to introduce a TCA Schema MM DTO/VO to represent this metadata (internal). Otherwise we'll have to deal with multiple array keys here and introduce possible keying mistakes that an object would prevent, and having IDE autocomplete for it.

    SaveToDatabaseFinisher.php:314

    And having an object would make this here prettier ;)

    SaveToDatabaseFinisher.php:411

    This might probably better be an exception instead?
  30. Garvin Hicking commented on patch set 13 07/24/26, 15:20

    I think I would prefer to have this be a feature and not a bugfix, I see a few things where it might go awry, and the savetoDatabaseFinisher is a good intrusion vector 😄
  31. Josua Vogel uploaded patch set 14 CR -1 V +1 07/26/26, 12:55

  32. core-ci voted on patch set 14 V +1 07/26/26, 13:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105420

  33. Josua Vogel marked it work in progress 07/26/26, 13:07

  34. Josua Vogel uploaded patch set 15 V +1 07/26/26, 13:16

  35. core-ci voted on patch set 15 V +1 07/26/26, 13:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105421

  36. Josua Vogel commented on patch set 15 07/26/26, 14:30

    This change is ready for review.

    Reply

    Done

    Reply

    I reworked the solution. RelationHandler is used now 😊

    SaveToDatabaseFinisher.php:284 Reply

    Done

    SaveToDatabaseFinisher.php:314 Reply

    Done

    SaveToDatabaseFinisher.php:411 Reply

    Done
  37. Garvin Hicking commented on patch set 15 CR +1 V +1 07/28/26, 11:27

    Thanks for the rework, that was well worth it I think. I tested this with tx_blogexample_domain_model_blog and the YAML example you provided, in insert and update mode. Worked for me out of the box.
  38. Oliver Klee voted on patch set 15 V +1 07/28/26, 11:32

  39. Josua Vogel uploaded patch set 16 CR +1 V +1 07/30/26, 13:34

  1. core-ci voted on patch set 16 V -1 07/30/26, 13:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105694

  2. Josua Vogel uploaded patch set 17 V -1 07/30/26, 14:02

  3. core-ci voted on patch set 17 V -1 07/30/26, 14:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105697

  4. Josua Vogel uploaded patch set 18 V -1 07/30/26, 14:17

  5. core-ci voted on patch set 18 V +1 07/30/26, 14:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105699

  6. Oliver Klee voted on patch set 18 V +1 08/02/26, 08:53

  7. Garvin Hicking voted on patch set 18 CR +1 V +1 08/04/26, 07:12

  8. Benni Mack uploaded patch set 19 CR +1 V +1 09/02/26, 22:06

  9. core-ci voted on patch set 19 V +1 09/02/26, 22:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107689

  10. Oliver Klee voted on patch set 19 V +1 09/03/26, 06:51

  11. Simon Schaufelberger voted on patch set 19 CR +1 V +1 09/03/26, 09:04

  12. Stefan Bürk commented on patch set 19 09/03/26, 10:16

    ext_tables.sql:1

    Not getting this .. if it is not multi-table relations, than the tablenames is superflous or not ? (cosmetic/always the same value anyway) ... or not ? And if multi values lands in it - why not declaring it as multi-table relation to have that outcome ? And even if required - the other fields are still created by DefaultTcaSchema or not, so that should only provide the tablenames column anyway ?
  13. Josua Vogel commented on patch set 19 09/03/26, 11:01

    ext_tables.sql:1 Reply

    @benni@typo3.org has to answer that — he added the code :D
  14. Benni Mack commented on patch set 19 09/03/26, 22:51

    ext_tables.sql:1 Reply

  15. Benni Mack commented on patch set 20 CR +1 V +1 09/14/26, 08:20

    Published edit on patch set 19.
  16. core-ci voted on patch set 20 V -1 09/14/26, 08:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108495

  17. Benni Mack commented on patch set 21 V -1 09/14/26, 09:32

    Published edit on patch set 20.
  18. Benni Mack commented on patch set 21 09/14/26, 09:32

    ext_tables.sql:1 Reply

    Done
  19. core-ci voted on patch set 21 V -1 09/14/26, 09:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108505

  20. Benni Mack uploaded patch set 22 V -1 09/14/26, 10:11

  21. core-ci voted on patch set 22 V +1 09/14/26, 10:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108513

  22. Stefan Bürk commented on patch set 22 CR -2 09/16/26, 08:31

    Needs deeper look and investigation - just had the behaviour that a submission got totally and silently lost. And it seams that this had not been found by the tests, thus the -2 on this. Putting this on my table for later full and deep review, analysis and verification.
  23. Josua Vogel commented on patch set 22 10/05/26, 06:11

    Reply Unresolved

    @stefan@buerk.tech any update on this topic?
  24. Josua Vogel uploaded patch set 23 V +1 10/07/26, 14:37

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  25. core-ci voted on patch set 23 V +1 10/07/26, 14:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110342