Bug #81855
closedAdd new record wizard fails on Save&Close with "select" field and MM setted
0%
Description
Hi all,
I've this TCA for a table named as "tx_myext_domain_model_sap":
'ptric' => array(
'exclude' => 1,
'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:tx_myext_domain_model_sap.ptric',
'config' => array(
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_usersdbterminali_domain_model_plan',
'MM' => 'tx_myext_sap_plan_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => array(
'add' => Array(
'module' => array(
'name' => 'wizard_add',
),
'type' => 'script',
'title' => 'Create new',
'icon' => 'add.gif',
'params' => array(
'table' => 'tx_myext_domain_model_plan',
'pid' => '###CURRENT_PID###',
'setValue' => 'prepend'
),
),
),
),
),
With that configuration, we can add a new record in table "tx_myext_domain_model_plan" and relate that in field tx_myext_domain_model_sap.ptric.
When I do this steps:
- add new record
- fill all mandatory fields
- click on "Save and close button"
The field "ptric" in "tx_myext_domain_model_sap" record, loose all old values and contains new "tx_myext_domain_model_plan" record uid, and another arbitrary "tx_myext_domain_model_plan" record id (see screenshoot).
I found the problem in typo3/sysext/backend/Classes/Controller/Wizard/AddController.php, in the function "main".
//[...]
$result = $formDataCompiler->compile($input);
$currentParentRow = $result['databaseRow'];
//[...]
in my case, $currentParentRow['ptric'] is equals to value "3"(it's the count of related plan records). The true values are placed in mm table.
That value is forwarded until the typo3/sysext/core/Classes/Database/RelationHandler.php, when the core deletes "all not-used relations":
//[...]
//Here $removeClauses was built using iteration on $oldMMs array which contains value "3".
//This value is wrong, it's the count of related record and not uid list of related records.
$where = $uidLocal_field . '=' . (int)$uid . $deleteAddWhere . $additionalWhere_tablenames . $additionalWhere;
$GLOBALS['TYPO3_DB']->exec_DELETEquery($MM_tableName, $where);
//[...]
Thank you,
Gianluca
Files