Project

General

Profile

Actions

Bug #81855

closed

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

Added by Gianluca Strafella over 7 years ago. Updated over 6 years ago.

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

0%

Estimated time:
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


Files

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

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #76863: MM Relation with selectMultipleSideBySide Field - Add wizard resets the MM RelationClosedThomas Hohn2016-06-29

Actions
Related to TYPO3 Core - Bug #82016: Wizards add still not working with MMClosed2017-08-01

Actions
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 Closed2017-09-12

Actions
Actions #1

Updated by Georg Ringer over 7 years ago

  • Status changed from New to Needs Feedback

please check out #76863 as it has been solved recently

Actions #2

Updated by Georg Ringer over 7 years ago

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

Updated by Gianluca Strafella over 7 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

Actions #4

Updated by Anke Altintop over 7 years ago

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

Actions #5

Updated by Riccardo De Contardi over 7 years ago

  • Status changed from Needs Feedback to New
Actions #7

Updated by Riccardo De Contardi about 7 years ago

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

Updated by Riccardo De Contardi about 7 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
Actions #9

Updated by Kevin Ditscheid over 6 years ago

Solved in #82461 please close

Actions #10

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from New to Closed

@Kevin no-lastname-given 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.

Actions

Also available in: Atom PDF