Review main Merged

70844[FEATURE] Auto creation of MM tables from TCA

Christian Kuhn CR +2 V +2 Hard +539 −69 updated 07/31/23, 15:49

Commit message

Specification of proper MM table layouts within TYPO3
has been troublesome ever since. There is a huge
amount of possible "MM_*" TCA column field properties
that have impact on a "true" MM table layout. Neither
core itself, nor extensions tend to get that right.

To simplify extension developers life, this patch
adds a "default TCA schema" definition for MM tables.
Extension developers are encouraged to drop their
"MM" table definitions from ext_tables.sql.
By doing so, they hand over control of those tables to
the core, so core can manage and adapt schema if needed.

The impact is shown with irre_tutorial extension: It
can drop two definitions from ext_tables.sql, as well as
ext:core's ext_tables.sql, which drops the specification
of sys_category_record_mm. ext:styleguide has cases, too.

Next to the business code in DefaultTcaSchema, the
patch adds a series of @todo comments to the involved
code, pointing out issues with current MM handling.
This feature patch acts as a pre-patch to fix these.

Review

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

Issues 1

Files 12

Review log 1624

  1. Christian Kuhn uploaded patch set 1 08/31/21, 14:53

  2. core-ci voted on patch set 1 V -1 08/31/21, 15:20 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15945

  3. Christian Kuhn uploaded patch set 2 08/31/21, 15:21

  4. core-ci voted on patch set 2 V -1 08/31/21, 15:50 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15951

  5. Christian Kuhn uploaded patch set 3 08/31/21, 16:15

  6. core-ci voted on patch set 3 V -1 08/31/21, 16:29 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15957

  7. Christian Kuhn uploaded patch set 4 08/31/21, 16:38

  8. core-ci voted on patch set 4 V -1 08/31/21, 16:56 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15959

  9. core-ci voted on patch set 4 V +1 08/31/21, 17:06 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15959

  10. Christian Kuhn uploaded patch set 5 08/31/21, 18:16

  11. core-ci voted on patch set 5 V +1 08/31/21, 18:39 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15963

  12. Christian Kuhn uploaded patch set 6 08/31/21, 18:40

  13. Christian Kuhn voted on patch set 6 CR -2 08/31/21, 18:44

  14. core-ci voted on patch set 6 V +1 08/31/21, 18:58 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15964

  15. Christian Kuhn uploaded patch set 7 08/31/21, 19:23

  16. core-ci voted on patch set 7 V +1 08/31/21, 19:42 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15965

  17. Christian Kuhn voted on patch set 7 CR 0 08/31/21, 19:49

  18. Stefan Bürk commented on patch set 7 V +1 CR +1 08/31/21, 22:41

    Had thought about the one or other thing, but fine with the implementation. Tested it locally also against mssql (subset functional tests). Just added comment for postgres test disabling as note. No blocker for this patch, as it should addressed by a seperate patch.

    CategoryCollectionTest.php:125

    Just to commenting first findings for why to disable for postgres, not as blocker for this patch. Firstly the fixture dataset has no sorting/sorting_foreign values declared for the relation table. Secondly the testing FunctionalTestCase->importCSVDataSet() method is plain sql insert and as such do not handle the "auto sorting" caluclation, datahandler would take care of. As such, the relation table has all "sortings" as zero in there. Thirdly the CategoryCollection class defines the joins, but do not respect sorting fields at all in the query to retrieve the relation collection records. So I would guess if 1/2 would be fixed, postgres 9.6/10/11/12 would be green but would be broken for postgres 12/13 again, because of non determistic query building. As it do not fails for mssql, mysql and mariadb I think having the test excludion for postgres is okay and should be fixed in a seperate patch (and further investigated).
  19. Christian Kuhn commented on patch set 7 09/01/21, 04:51

    CategoryCollectionTest.php:125 Reply

    thank you. great analysis! let's bug fix this with a dedicated patch.
  20. Benni Mack voted on patch set 7 V +2 CR +2 09/01/21, 09:40

  21. Benni Mack merged patch set 8 09/01/21, 09:40

  22. Andreas Kienast commented on patch set 8 09/16/21, 14:32

    RelationHandler.php:1650

    So this means it's discouraged to use the same table to feed two independent select fields distinguished by their `fieldname`?
  23. Christian Kuhn commented on patch set 8 09/16/21, 16:24

    RelationHandler.php:1650 Reply

    No. One table with two fields having an MM relation to the same table (2 fields in tt_content to sys_category) gives headaches as described in the @todo scenario above. There are use cases for that, but the handling is problematic when editing the local side. We'll have to tackle that somehow, even though i'm unsure how exactly this will end up. This @todo comment here just says that having both MM_match_fields (foreign side) AND MM_oppositeUsage (local side) is redundant information: Both TCA specifications carry the same information. So one of both *could* potentially fall (probably MM_match_fields). That's what this comment is about.
  24. Christian Kuhn commented on patch set 8 07/31/23, 15:49

    RelationHandler.php:1650 Reply

    Done