#81315Translation of inline elements fails, when only one item is to be translated
Description
When i try to translate a page with an inline field with only 1 entry, the translation doesn’t generate the translated entry.
It is okay for more than 1 entry.
The error resides in the DataMapProcessor::synchronizeInlineRelations function on row 581.
$sanitizedValue = $this->sanitizationMap[$item->getTableName()][$item->getId()][$fieldName] ?? null;
if (
!empty($missingAncestorIds) && $item->isNew() && $sanitizedValue !== null
&& count(GeneralUtility::trimExplode(',', $sanitizedValue)) === count($missingAncestorIds)
) {
$this->modifyDataMap(
$item->getTableName(),
$item->getId(),
[$fieldName => $sanitizedValue]
);
return;
}
If $sanitizedValue is an empty string, “GeneralUtility::trimExplode(‘,’, $sanitizedValue)” WILL return an array with one empty string as a value, therefore the count is 1 which is wrong on inline elements with 1 entry.
The check “$sanitizedValue !== null” is therefore no adequate check for this string (and in general for strings, too :p) and should be “!empty($sanitizedValue)”.
I attached a patchfile (generated on TYPO3 v8.7.1) which will do exactly that.
If you want to reproduce this error, here my TCA-Column (defined in “pages” & “pages_language_overlay”, 1:N, table “tx_pbsite_domain_model_slideritem” is fully translatable):
'slider' => [
'exclude' => 1,
'label' => 'LLL:EXT:pb_site/Resources/Private/Language/locallang.xlf:pages.fields.slider',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_pbsite_domain_model_slideritem',
'foreign_match_fields' => [
'field_foreign' => 'sliderwelcome'
],
'foreign_label' => 'title',
'foreign_sortby' => 'sorting',
'foreign_field' => 'uid_foreign',
'foreign_table_field' => 'tablename',
'appearance' => [
'collapseAll' => 1,
],
'maxItems' => 999,
'enabledControls' => [
'sort' => '1',
'delete' => '1',
],
'behaviour' => [
'allowLanguageSynchronization' => 1,
'localizeChildrenAtParentLocalization' => 1
],
]
],Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.