Project

General

Profile

Actions

Bug #99980

open

DataHandler "processRemapStack" fails settings correct values for e.g. passthrough fields like "l10n_parent" (sets values from "remapAction" before)

Added by Denis Mir almost 2 years ago. Updated over 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
Start date:
2023-02-17
Due date:
% Done:

0%

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

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

image (1).png (33.9 KB) image (1).png Database Denis Mir, 2023-05-09 09:07
image.png (86.1 KB) image.png Backend Denis Mir, 2023-05-09 09:07
Actions #1

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

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.

Actions

Also available in: Atom PDF