Project

General

Profile

Actions

Bug #101936

open

Duplicate MM records after copy

Added by Philipp Kitzberger about 1 year ago. Updated 4 months ago.

Status:
Accepted
Priority:
Must have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2023-09-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

For TYPO3 11 (and 12) records with a bidirectional MM relations to themselves have duplicate MM records after copying them via DataHandler.

A prominent example would be EXT:news with its two columns related and related_from (stripped down to relevant parts):

EXT:news/Configuration/TCA/tx_news_domain_model_news.php:

        'related' => [
            'config' => [
                'type' => 'group',
                'allowed' => 'tx_news_domain_model_news',
                'foreign_table' => 'tx_news_domain_model_news',
                'MM_opposite_field' => 'related_from',
                'MM' => 'tx_news_domain_model_news_related_mm',
            ],
        ],
        'related_from' => [
            'config' => [
                'type' => 'group',
                'foreign_table' => 'tx_news_domain_model_news',
                'allowed' => 'tx_news_domain_model_news',
                'MM' => 'tx_news_domain_model_news_related_mm',
                'readOnly' => 1,
            ],
        ],

Scenario:
  • Install EXT:news
  • Create a folder with 2 news records, one refering to the other (via related column)
  • Copy that folder
Original folder Copied folder

Expected result: 2nd folder with 2 news records, one refering one time to the other
Actual result: 2nd folder with 2 news records one refering three times to the other

With TYPO3 10 this worked as expected. And since the TCA in news hadn't changed, I assume it's a TYPO3 core issue. Plus I can reproduce it with pages records as well.

Hint: when unsetting the TCA for the related_from field, it's working flawlessly.


Files

Actions #1

Updated by Philipp Kitzberger about 1 year ago

  • Subject changed from Duplicate mm records after copy to Duplicate MM records after copy
Actions #2

Updated by Philipp Kitzberger about 1 year ago

  • Description updated (diff)
Actions #3

Updated by Oliver Hader about 1 year ago

tt_content and sys_category in the core are using the same opposite reference.

Tests at https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Tests/Functional/DataScenarios/CategoryOneToOne/Modify/ActionTest.php#L213-L226 could be extended to reflect that better (I remember there had been more tests for MM in the past... hm...)

Actions #4

Updated by Oliver Hader about 1 year ago

  • Status changed from New to Accepted

Confirmed in TYPO3 v12 & master (90d885c7782f255028148e90509e4686685ef02f)

  • create sys_category record "category"
  • create tt_content element "test" + reference to sys_category "category"
  • duplicate sys_category item "category" + rename clone to "clone"
    → content element has references to categories "category" and "clone"

There should be a new behavior on the opposite side (sys_category) in the example above, that would control whether to clone all references if the opposite record is duplicated.

Actions #5

Updated by Meelis Karulin 4 months ago · Edited

Even worse, when you save the affected record via the TYPO3 backend, the relations get deleted from the MM table (Both the original and the duplicates). This causes dataloss.
Please rise the priority of this issue.

Actions #6

Updated by Meelis Karulin 4 months ago

  • Priority changed from Should have to Must have
Actions

Also available in: Atom PDF