Issue Bug New Orphaned

#108801export / import does not respect IRRE-relations in TCA columnsOverrides

Andreas Häfner 01/29/26, 09:30 updated 01/29/26, 09:30

Description

Exporting and importing Elements with inline-relations, defined only in columnsOverrides, get not respected on export.
On Import the counting relation-field is taken as uid of foreign_table!
The foreign_field of the falsely selected foreign record gets set to the new created uid.
This is results in unpredictable scrambled relations on larger Imports!

A minimal example including TCA, used cli-commands and SQL-Results before and after Import is following:
This example should reproduce the error for testing.

TCA relation

Configuration/TCA/tx_test_relation.php

<?php

defined('TYPO3') or die();

return call_user_func(function (): array {
    $tableName = 'tx_test_relation';

    return [
        'ctrl' => [
            'title' => $tableName,
            'label' => 'label',
            'tstamp' => 'tstamp',
            'crdate' => 'crdate',
            'hideTable' => false,
            'default_sortby' => 'ORDER BY cruser_id DESC',
            'delete' => 'deleted',
            'sortby' => 'sorting',
            'enablecolumns' => [
                'disabled' => 'hidden',
                'starttime' => 'starttime',
                'endtime' => 'endtime',
            ],
            'searchFields' => '',
            'security' => [
                'ignorePageTypeRestriction' => true,
            ],
        ],
        'types' => [
            '0' => [
                'showitem' => 'label, tt_content',
            ],
        ],
        'columns' => [

            'label' => [
                'exclude' => true,
                'label' => $tableName . 'label',
                'config' => [
                    'type' => 'input',
                    'size' => 60,
                    'eval' => 'trim',
                ],
            ],

            'tt_content' => [
                'label' => 'tt_content',
                'config' => [
                    'type' => 'passthrough',
                    // same result with backward relation
                    //'type' => 'inline',
                    //'foreign_table' => 'tt_content',
                    //'foreign_field' => 'tx_test_relation', 
                ],
            ],
        ],
    ];
});

TCA tt_content

Configuration/TCA/Overrides/tt_content.php

<?php

defined('TYPO3') or die();

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
    'tt_content',
    [
        'tx_test_relation' => [
            'label' => 'tx_test_relation',
            'exclude' => 1,
            'config' => [
                'type' => 'passthrough',
                /* impexp works with direct inclusion of relation
                'type' => 'inline',
                'foreign_table' => 'tx_test_relation',
                'foreign_field' => 'tt_content',
                'minitems' => 1,
                */
            ]
        ],
    ]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
    'tt_content',
    'tx_test_relation',
);

// if inline is defined via columnsOverrides, impexp produces error
$GLOBALS['TCA']['tt_content']['types']['header']['columnsOverrides']['tx_test_relation']['config'] = [
    'type' => 'inline',
    'foreign_table' => 'tx_test_relation',
    'foreign_field' => 'tt_content',
    'minitems' => 1,
];

Before import:

SELECT uid, pid, CType, header, tx_test_relation FROM tt_content WHERE pid IN (758,759);
+------+-----+--------+------------+------------------+
| uid  | pid | CType  | header     | tx_test_relation |
+------+-----+--------+------------+------------------+
| 1653 | 758 | header | testexport |                3 | <- holds 3 items
| 1654 | 759 | header | exportme   |                2 | <- holds 2 items, should be exported
+------+-----+--------+------------+------------------+
SELECT uid,pid,label,tt_content FROM tx_test_relation;
+-----+-----+------------+------------+
| uid | pid | label      | tt_content |
+-----+-----+------------+------------+
|   1 | 758 | Uid 1      |       1653 |
|   2 | 758 | Uid 2      |       1653 |
|   3 | 758 | Uid 3      |       1653 |
|   4 | 759 | exportme 1 |       1654 |
|   5 | 759 | exportme 2 |       1654 |
+-----+-----+------------+------------+

Commands for export and import: (Same results for --type=t3d)

bin/typo3 impexp:export --type=xml --pid 759 --levels 3 --table=tt_content --table=tx_test_relation --exclude-disabled-records -- TestExport
> [OK] Exporting to fileadmin/user_upload/_temp_/importexport/TestExport.xml succeeded. 
bin/typo3 impexp:import -- fileadmin/user_upload/_temp_/importexport/TestExport.xml -759
> [OK] Importing fileadmin/user_upload/_temp_/importexport/TestExport.xml to page -759 succeeded.

After import:

SELECT uid, pid, CType, header, tx_test_relation FROM tt_content WHERE pid IN (758,759,778);
+------+-----+--------+------------+------------------+
| uid  | pid | CType  | header     | tx_test_relation |
+------+-----+--------+------------+------------------+
| 1653 | 758 | header | testexport |                2 |
| 1654 | 759 | header | exportme   |                4 |
| 1667 | 778 | header | exportme   |                1 | <- new imported
+------+-----+--------+------------+------------------+

SELECT uid,pid,label,tt_content FROM tx_test_relation;
+-----+-----+------------+------------+
| uid | pid | label      | tt_content |
+-----+-----+------------+------------+
|   1 | 758 | Uid 1      |       1653 |
|   2 | 758 | Uid 2      |       1667 | <- uid 2 taken from tt_content[uid=1654].tx_test_relation = 2
|   3 | 758 | Uid 3      |       1653 |
|   4 | 759 | exportme 1 |       1654 |
|   5 | 759 | exportme 2 |       1654 |
|   6 | 778 | exportme 2 |       1654 | <- new imported
|   7 | 778 | exportme 1 |       1654 | <- new imported
+-----+-----+------------+------------+

exported XML (shortend)

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3RecordDocument>
    <header type="array">
        <XMLversion>1.0</XMLversion>
        <meta type="array">
            <title></title>
            <description></description>
            <notes></notes>
            <packager_username>_cli_</packager_username>
            <packager_name></packager_name>
            <packager_email></packager_email>
            <TYPO3_version>13.4.23</TYPO3_version>
            <created>Thu 29. January 2026</created>
        </meta>
        <static_tables index="relStaticTables" type="array"></static_tables>
        <excludeMap type="array"></excludeMap>
        <softrefCfg type="array"></softrefCfg>
        <extensionDependencies type="array"></extensionDependencies>
        <charset>utf-8</charset>
        <pagetree type="array">
            <node index="759" type="array">
                <uid>759</uid>
            </node>
        </pagetree>
        <records type="array">
            <table index="pages" type="array">
                <rec index="759" type="array">
                    <uid>759</uid>
                    <pid>1</pid>
                    <title>exportme</title>
                    <relations index="rels" type="array"></relations>
                    <softrefs type="array"></softrefs>
                </rec>
            </table>
            <table index="tt_content" type="array">
                <rec index="1654" type="array">
                    <uid>1654</uid>
                    <pid>759</pid>
                    <title>exportme</title>
                    <relations index="rels" type="array"></relations>
                    <softrefs type="array"></softrefs>
                </rec>
            </table>
            <table index="tx_test_relation" type="array">
                <rec index="4" type="array">
                    <uid>4</uid>
                    <pid>759</pid>
                    <title>exportme 1</title>
                    <relations index="rels" type="array"></relations>
                    <softrefs type="array"></softrefs>
                </rec>
                <rec index="5" type="array">
                    <uid>5</uid>
                    <pid>759</pid>
                    <title>exportme 2</title>
                    <relations index="rels" type="array"></relations>
                    <softrefs type="array"></softrefs>
                </rec>
            </table>
        </records>
        <pid_lookup type="array">
            <page_contents index="1" type="array">
                <table index="pages" type="array">
                    <item index="759">1</item>
                </table>
            </page_contents>
            <page_contents index="759" type="array">
                <table index="tt_content" type="array">
                    <item index="1654">1</item>
                </table>
                <table index="tx_test_relation" type="array">
                    <item index="4">1</item>
                    <item index="5">1</item>
                </table>
            </page_contents>
        </pid_lookup>
    </header>
    <records type="array">
        <tablerow index="pages:759" type="array">
            <fieldlist index="data" type="array">
                <field index="uid" type="integer">759</field>
                <field index="pid" type="integer">1</field>
                <field index="tstamp" type="integer">1769598933</field>
                <field index="crdate" type="integer">1769598509</field>
                <field index="deleted" type="integer">0</field>
                <field index="hidden" type="integer">0</field>
                <field index="starttime" type="integer">0</field>
                <field index="endtime" type="integer">0</field>
                <field index="title">exportme</field>
                <field index="slug">/exportme</field>
                <field index="doktype" type="integer">1</field>
                <field index="TSconfig" type="NULL"></field>
                <field index="is_siteroot" type="integer">0</field>
                [...]
            </fieldlist>
            <related index="rels" type="array"></related>
        </tablerow>
        <tablerow index="tt_content:1654" type="array">
            <fieldlist index="data" type="array">
                <field index="uid" type="integer">1654</field>
                <field index="pid" type="integer">759</field>
                <field index="tstamp" type="integer">1769675355</field>
                <field index="crdate" type="integer">1769607299</field>
                <field index="sorting" type="integer">1</field>
                <field index="CType">header</field>
                <field index="header">exportme</field>
                <field index="colPos" type="integer">0</field>
                [...]
                <field index="tx_test_relation" type="integer">2</field>
            </fieldlist>
            <related index="rels" type="array"></related>
        </tablerow>
        <tablerow index="tx_test_relation:4" type="array">
            <fieldlist index="data" type="array">
                <field index="uid" type="integer">4</field>
                <field index="pid" type="integer">759</field>
                <field index="tstamp" type="integer">1769675355</field>
                <field index="crdate" type="integer">1769675355</field>
                <field index="deleted" type="integer">0</field>
                <field index="hidden" type="integer">0</field>
                <field index="starttime" type="integer">0</field>
                <field index="endtime" type="integer">0</field>
                <field index="sorting" type="integer">1</field>
                <field index="label">exportme 1</field>
                <field index="tt_content" type="integer">1654</field>
            </fieldlist>
            <related index="rels" type="array"></related>
        </tablerow>
        <tablerow index="tx_test_relation:5" type="array">
            <fieldlist index="data" type="array">
                <field index="uid" type="integer">5</field>
                <field index="pid" type="integer">759</field>
                <field index="tstamp" type="integer">1769675355</field>
                <field index="crdate" type="integer">1769675355</field>
                <field index="deleted" type="integer">0</field>
                <field index="hidden" type="integer">0</field>
                <field index="starttime" type="integer">0</field>
                <field index="endtime" type="integer">0</field>
                <field index="sorting" type="integer">2</field>
                <field index="label">exportme 2</field>
                <field index="tt_content" type="integer">1654</field>
            </fieldlist>
            <related index="rels" type="array"></related>
        </tablerow>
    </records>
</T3RecordDocument>

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] export / import does not respect IRRE-relations in TCA columnsOverrides Resolves: #108801 Releases: main