Bug #73761
closedMoving or deleting in flexform section lists not possible when using workspaces and creating first version
100%
Description
There is an issue when using workspaces and section lists in flexforms. This bug appeared in combination with templavoila but as far as i understand the code, this can happen to all flexform fields. This bug will appear when trying to versionize a content element the first time that contains a flexform section list.
Steps to reproduce:
In live workspace add a new content element to a page that contains a flexform section list and add two section items minimum. Switch to a custom workspace and change the ordering of the section items (deleting of section items also doesn't work). Save it and open it again. Sections items were not moved or deleted. Do this again and it works.
Took me 16 hours of debugging to find the code passage that causes this bug. In TYPO3\CMS\Core\DataHandling\DataHandler->checkValue_flex() line 2308 a post array is read.
// Action commands (sorting order and removals of elements) $actionCMDs = GeneralUtility::_GP('_ACTION_FLEX_FORMdata'); if (is_array($actionCMDs[$table][$id][$field]['data'])) { ...
This post array contains for example
$actionCMDs[tt_content][1234][tx_myext_myflex][data][sDEF][lDEF][some_section][el][_ACTION][...]
If there is no versionized record for this record yet, the uid 1234 is the uid of the original record. But this is wrong because according to the code in checkValue_flex this has to be the id of the versionized record, which doesn't exist yet. Therefore the condition
if (is_array($actionCMDs[$table][$id][$field]['data'])) {
will not get true. So no deletion or moving will happen.
If the record is versionized already the uid in the post array is correct and moving and deleting works fine.