#106917First save of table field fails when delimiter field is missing
Description
Prerequisite: “Table” content element with a text field that has renderType = textTable but without a table_delimiter field.
Saving such a table element the first time causes all columns to be merged into a single cell with a broken separator: ab.
This happens on TYPO3 v12.4.33 and TYPO3 v13.4.14
Steps to reproduce
- Normal table content element shipped with TYPO3 core must be available
- Remove the
table_delimiterfrom the element (to reduce cognitive load for editors) by overriding TCA in e.g.Configuration/TCA/Overrides/tt_content.php:$GLOBALS['TCA']['tt_content']['palettes']['tableconfiguration']['showitem'] = 'table_enclosure'; - Web > Page: Create new content element “Table”
- Add a second column
- Type “a” in first column, “b” in second
- Save
The element will be saved, but the table wizard will show a single field only, with values “a b”. Between a and b is a broken non-displayable character.
When adding a second column again and saving again, all is fine.
Impact
This also happens when creating custom content elements with flux or mask that don’t have a delimiter field by default.
Cause
TYPO3\CMS\Backend\Form\Element\TextTableElement::getTableWizard() is the source of the problem. It checks if a delimiter is configured with this code:
$delimiter = ($row['table_delimiter'][0] ?? false) ? chr((int)$row['table_delimiter'][0]) : '|';
This is fine as long as a table_delimiter field is defined, because then databaseRow[table_delimiter] is an array:
["table_delimiter"]=> array(1) { [0]=> string(3) "124" }
When the content element does not have this field, databaseRow[table_delimiter] is a string:
["table_delimiter"]=> string(3) "124"
The array key check $row['table_delimiter'][0] does a substr in this case, returning “1” as ASCII number code for the delimiter. This leads to the broken delimiter character later on.
When saving this element a second time, table_delimiter is an integer now:
["table_delimiter"]=> int(124)
A [0] access does not do a substring now but fails, leading to the fallback delimiter value “|”.