#106911Import/Export: Importer creates wrong sys_category_record_mm entries
Description
Scenario:
News records + relations should be imported from one system to another.
The news records have categories with this configuration:
‘categories’ => [
‘exclude’ => true,
‘label’ => $ll . ‘tx_news_domain_model_news.categories’,
‘config’ => [
‘type’ => ‘select’,
‘renderType’ => ‘selectTree’,
‘treeConfig’ => [
// ‘dataProvider’ => \GeorgRinger\News\TreeProvider\DatabaseTreeDataProvider::class,
‘parentField’ => ‘parent’,
‘appearance’ => [
‘showHeader’ => true,
‘expandAll’ => true,
‘maxLevels’ => 99,
],
],
‘MM’ => ‘sys_category_record_mm’,
‘MM_match_fields’ => [
‘fieldname’ => ‘categories’,
‘tablenames’ => ‘tx_news_domain_model_news’,
],
‘MM_opposite_field’ => ‘items’,
‘foreign_table’ => ‘sys_category’,
‘foreign_table_where’ => ‘ AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) ORDER BY sys_category.sorting’,
‘size’ => 30,
‘minitems’ => 0,
‘maxitems’ => 99,
‘behaviour’ => [
‘allowLanguageSynchronization’ => true,
],
],
],
The target system already has category records.
After the import, some sys_category_record_mm entries exist like these:
+-----------+-------------+---------------------------+------------+---------+-----------------+ | uid_local | uid_foreign | tablenames | fieldname | sorting | sorting_foreign | +-----------+-------------+---------------------------+------------+---------+-----------------+ | 1 | 14638 | tx_news_domain_model_news | categories | 0 | 1 | | 422 | 14638 | tx_news_domain_model_news | categories | 0 | 2 | +-----------+-------------+---------------------------+------------+---------+-----------------+
But: the original news record only had a relation to the category uid “422”. The relation to “1” was added incorrectly.
After a long debugging session I could find some clues:
- DataHandler calls checkValueForGroupFolderSelect with the value “1”.
- The value “1” is converted to an array [0 => 1]
- Then, the method checkValue_group_select_processDBdata is called in an else branch
- Inside this method, the RelationHandler is booted with the array from before.
$dbAnalysis->start($newRelations, $tables, ‘’, 0, $currentTable, $tcaFieldConf);
The interesting part is, the third argument is called with an empty string (this is the parameter for the MM table).
This eventually leads to RelationHandler calling readList and storing the value to its property “itemArray”.
Back to checkValue_group_select_processDBdata, DataHandler stores the result in another else branch:
$this->dbAnalysisStore[] = [$dbAnalysis, $tcaFieldConf[‘MM’], $id, $prep, $currentTable];
Finally, DataHandler calls dbAnalysisStoreExec at the end of process_datamap, which leads to RelationHandler writing the wrong MM relation with the uid “1”.
So the problem is, that the import writes the MM value with the category count value.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Related issues 1
History 3
-
Nikita Hovratov changed description <span data-processor="relativetime" data-value="2025-06-18T18:16:06+00:00" > 06/18/25, 18:16 </span>
-
Benni Mack changed Related to #91580 <span data-processor="relativetime" data-value="2026-11-15T15:05:00+00:00" > 11/15/26, 15:05 </span>
-
Benni Mack commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-11-15T15:05:26+00:00" > 11/15/26, 15:05 </span>
Fixed with #91580