Bug #81855

Add new record wizard fails on Save&Close with "select" field and MM setted

Added by Gianluca Strafella over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Start date:
2017-07-13
Due date:
% Done:

0%

TYPO3 Version:
7
PHP Version:
5.6
Tags:
tca wizard_add
Complexity:
medium
Is Regression:
Sprint Focus:

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

core-tca-error.png View (51.3 KB) Gianluca Strafella, 2017-07-13 15:59


Related issues

Related to TYPO3 Core - Bug #76863: MM Relation with selectMultipleSideBySide Field - Add wizard resets the MM Relation Closed 2016-06-29
Related to TYPO3 Core - Bug #82016: Wizards add still not working with MM Closed 2017-08-01
Related to TYPO3 Core - Bug #82461: Backend/TCA: fieldControl->addRecord removes old relations after creating an new entry in the foreign table for the new relation Closed 2017-09-12

History

#1 Updated by Georg Ringer over 2 years ago

  • Status changed from New to Needs Feedback

please check out #76863 as it has been solved recently

#2 Updated by Georg Ringer over 2 years ago

  • Related to Bug #76863: MM Relation with selectMultipleSideBySide Field - Add wizard resets the MM Relation added

#3 Updated by Gianluca Strafella over 2 years ago

Hi,
sure the problem is the same but patch in https://forge.typo3.org/issues/76863#note-27 does not work in my version (TYPO3 7.6.20).

This is the problem:

// Check the row for its datatype. If it is an array it stores the relation
// to other rows. Implode it into a comma separated list to be able to restore the stored
// values after the wizard falls back to the parent record
$currentValue = $currentParentRow[$this->P['field']];
if (is_array($currentValue)) {
     $currentValue = implode(',', array_column($currentValue, 'uid'));
}

This is the dump of variable "$currentParentRow[$this->P['field']]" in my case:

array(2 items)
   0 => "51" (2 chars)
   1 => "46" (2 chars)

and so, implode statement fails.

Gianluca

#4 Updated by Anke Altintop over 2 years ago

I can confirm that is not solved in Typo3 8.7.* either. The problem remains the same even with the integrated patch

#5 Updated by Riccardo De Contardi over 2 years ago

  • Status changed from Needs Feedback to New

#7 Updated by Riccardo De Contardi about 2 years ago

  • Related to Bug #82016: Wizards add still not working with MM added

#8 Updated by Riccardo De Contardi about 2 years ago

  • Related to Bug #82461: Backend/TCA: fieldControl->addRecord removes old relations after creating an new entry in the foreign table for the new relation added

#9 Updated by Kevin Ditscheid over 1 year ago

Solved in #82461 please close

#10 Updated by Riccardo De Contardi over 1 year ago

  • Status changed from New to Closed

@Kevin Ditscheid thank you for your feedback - closed.

If you think that this is the wrong decision or experience the issue again, please reopen it or open a new issue with a reference to this one.

Also available in: Atom PDF