Bug #99980
openDataHandler "processRemapStack" fails settings correct values for e.g. passthrough fields like "l10n_parent" (sets values from "remapAction" before)
0%
Description
I think we found a major bug in the DataHandlers `processRemapStack` function that needs to be fixed urgently.
$newValue = null;
foreach ($this->remapStack as $remapAction) {....}
The "newValue" which gets set as replacement value in the database is defined outside of the loop.
This leads to the case that a remapAction will get the value from the remapAction before.
// Process the arguments with the defined function:
if (!empty($remapAction['func'])) {
$callable = [$this, $remapAction['func']];
if (is_callable($callable)) {
$newValue = $callable(...$remapAction['args']);
}
}
// If array is returned, check for maxitems condition, if string is returned this was already done:
if (is_array($newValue)) {
$newValue = implode(',', $this->checkValue_checkMax($tcaFieldConf, $newValue));
// The reference casting is only required if
// checkValue_group_select_processDBdata() returns an array
$newValue = $this->castReferenceValue($newValue, $tcaFieldConf, $isNew);
}
This can happen when both of the conditions above evaluate to false. E.g. for passthrough fields there is no "$remapAction['func']".
This breaks for example the creation of inline records when "allowLanguageSynchronization" is enabled. In this case the "l10n_parent" field which is defined as passthrough gets the count of inline items set instead of the correct parent uid.
Files
Updated by Denis Mir over 1 year ago
Just as a note the "checkValueForInternalReferences" method is the reason why the "if (!empty($remapAction['func']))" condition is not being hit.
Updated by Denis Mir over 1 year ago
- File image (1).png image (1).png added
- File image.png image.png added
Here is an example which fails due to this bug as well. (manually creating translated items via the DataHandler)
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$cmd = [];
$data = [];
$data['tx_user_ext_domain_model_text'] = [
"NEW6459ee9332753637991034" => [
"pid" => 981,
"sys_language_uid" => 0,
"identifier" => 8514,
"label" => "Test A - Language 0"
],
"NEW6459ee944f3f0818025611" => [
"pid" => 981,
"sys_language_uid" => 1,
"identifier" => 8514,
"label" => "Test A - Language 1",
"l10n_parent" => "NEW6459ee9332753637991034"
],
"NEW6459ee9334c0d549539707" => [
"pid" => 981,
"sys_language_uid" => 0,
"identifier" => 8514,
"label" => "Test B - Language 0"
],
"NEW6459ee9451820725382473" => [
"pid" => 981,
"sys_language_uid" => 1,
"identifier" => 8514,
"label" => "Test B - Language 1",
"l10n_parent" => "NEW6459ee9334c0d549539707"
]
];
$dataHandler->start($data, $cmd);
$dataHandler->process_datamap();
The remapping for the translated items fails due to the passthrough "l10n_parent" field and gets as a value null.
I have attached the database and backend view after running the data handler.