Project

General

Profile

Actions

Bug #98322

closed

IRRE fields have limited TCA-options concerning mm-tables

Added by David Bruchmann about 2 years ago. Updated about 1 year ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Start date:
2022-09-10
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
tca table-auto-creation
Complexity:
Is Regression:
Sprint Focus:

Description

This code (of EXT:blog_example, table tx_blogexample_domain_model_person) should autocreate an mm-table with the field `fieldname` but it doesn't. The table is created but without that field.

        'tags' => [
            'label' => 'LLL:EXT:blog_example/Resources/Private/Language/locallang_db.xlf:tx_blogexample_domain_model_person.tags',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_blogexample_domain_model_tag', // needed by Extbase
                'MM' => 'tx_blogexample_domain_model_tag_mm',
                'MM_match_fields' => [
                    'fieldname' => 'tags',
                ],
                'appearance' => [
                    'useCombination' => 1,
                    'useSortable' => 1,
                    'collapseAll' => 1,
                    'expandSingle' => 1,
                ],
            ],
        ],
        'tags_special' => [
            'exclude' => true,
            'label' => 'LLL:EXT:blog_example/Resources/Private/Language/locallang_db.xlf:tx_blogexample_domain_model_person.tags_special',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_blogexample_domain_model_tag', // needed by Extbase
                'MM' => 'tx_blogexample_domain_model_tag_mm',
                'MM_match_fields' => [
                    'fieldname' => 'tags_special',
                ],
                'appearance' => [
                    'useCombination' => 1,
                    'useSortable' => 1,
                    'collapseAll' => 1,
                    'expandSingle' => 1,
                ],
            ],
        ],
Actions #1

Updated by David Bruchmann about 2 years ago

  • Description updated (diff)
Actions #2

Updated by Benni Mack about 2 years ago

  • Target version changed from 12.0 to 12.1
Actions #3

Updated by Benni Mack almost 2 years ago

  • Target version changed from 12.1 to 12.2
Actions #4

Updated by Benni Mack almost 2 years ago

  • Target version changed from 12.2 to 12.3
Actions #5

Updated by Gerrit Code Review almost 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77871

Actions #6

Updated by Gerrit Code Review almost 2 years ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77871

Actions #7

Updated by Christian Kuhn over 1 year ago

I think this is a side effect of the broken TCA in blog example, see this comment: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Configuration/TCA/tx_blogexample_domain_model_tag.php#L77

These relations should be fixed in blog_example.

Looking at "sys_category_record_mm" instead, the system gets it right: In general, "fieldname" and "tablenames" are only needed if the "local side" (in this case sys_category) can be the target of multiple "foreign side" tables. In this case, "MM_oppositeUsage" is set, and the system auto-creates the two fields in DefaultTcaSchema already.

In general, if you have only one "foreign side", the two fields "fieldname" and "tablename" are not needed, should be omitted, and "MM_match_fields" should not be declared. I explained a bit about the mess around "MM_match_fields" here: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70844/8/typo3/sysext/core/Classes/Database/RelationHandler.php#1650

In the end, we should actually get rid of "MM_match_fields" altogether, since according 'where' clauses are created automatically as soon as a local side is referenced by multiple foreign sides, which is indicated by the existence of "MM_oppositeUsage".

As such, I would prefer not to auto-create fields based on "MM_match_fields", since that TCA definition should vanish altogether, using it on the local side indicates a broken TCA, and currently adds more harm than good.

Actions #8

Updated by David Bruchmann over 1 year ago

Christian, as long as there is a (documented) working solution I don't mind.
I'll certainly come back to this issue for information but if the blog example is updated already that's perhaps not even required.
Currently I can't verify it in detail what you wrote, but I think you know better than most people about it.
Feel free to close the issue if you think it's not relevant anymore.

Actions #9

Updated by Benni Mack over 1 year ago

  • Target version changed from 12.3 to 12 LTS
Actions #10

Updated by Gerrit Code Review over 1 year ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77871

Actions #11

Updated by Benni Mack over 1 year ago

  • Target version changed from 12 LTS to Candidate for patchlevel
Actions #12

Updated by Gerrit Code Review over 1 year ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77871

Actions #13

Updated by Christian Kuhn about 1 year ago

Hey. We meanwhile fixed the core 'blog_example', the 'local' side (the tag table) no longer contains the MM_match_fields definition since it's a useless setting on this side. DefaultTcaSchema only looks at local side when creating the tables sql definition. I'll close here and will abandon the patch.

Actions #14

Updated by Christian Kuhn about 1 year ago

  • Status changed from Under Review to Rejected
Actions

Also available in: Atom PDF