#108994Exception when sorting content elements that are uniqueInPid and l10mode exclude
Description
Description
It is currently not possible manually sorting a field configured in TCA as both uniqueInPid and l10mode exclude, as it results in an exception, that the l18n_parent is an undefined array key. We use this combination in order to enforce a unique index-name for our SOLR index, that is unique per configuration folder but shared across localization. Removing exclude appends an integer to the index-name, as it must be strictly unique, but makes the exception go away. Removing uniqueInPid allows for multiple index-names of the same name and can cause a naming collision, but removes the exception as well. The usage of both is mutually exclusive. This was not an issue in Typo3 10.x, but must have been introduces in 11.x or 12.x.
*Steps to reproduce*
Configure a TCA field to be both eval => uniqueInPid and l10n_mode => exclude, and ctrl => sortby => sorting. Make sure, that all localization related fields are applied (transOrigPointerField, sys_language_uid, etc.). When a content element is manually moved, it creates an exception:
(1/1) #1476107295 TYPO3\CMS\Core\Error\Exception PHP Warning: Undefined array key "l18n_parent" in [...]/vendor/typo3/cms-core/Classes/DataHandling/DataHandler.php line 2650
*Observation*
The issue arises in the DataHandler’s public function getUnique($table, $field, $value, $id, $newPid = 0). When enforcing retrival of the localization parent from database, the issue goes away and sorting finishes without an exception:
$schema = $this->tcaSchemaFactory->get($table);
$tcaField = $schema->getField($field);
if ($tcaField->getTranslationBehaviour() === FieldTranslationBehaviour::Excluded && $schema->isLanguageAware()) {
$transOrigPointerField = $schema->getCapability(TcaSchemaCapability::Language)->getTranslationOriginPointerField()->getName();
// TEST: load 'l18n_parent' from db
if (!isset($this->checkValue_currentRecord[$transOrigPointerField]) && $id > 0) {
$record = BackendUtility::getRecord($table, $id, $transOrigPointerField);
if ($record && isset($record[$transOrigPointerField])) {
$this->checkValue_currentRecord[$transOrigPointerField] = $record[$transOrigPointerField];
}
}
// END TEST
$l10nParent = (int)$this->checkValue_currentRecord[$transOrigPointerField];
if ($l10nParent > 0) {
// Current record is a translation and l10n_mode "exclude" just copies the value from source language
return $value;
}
}
Example TCA
return [
'ctrl' => [
'title' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_labels.xlf:tx_dlf_metadata',
'label' => 'label',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
],
'iconfile' => 'EXT:dlf/Resources/Public/Icons/txdlfmetadata.png',
'rootLevel' => 0,
'searchFields' => 'label,index_name',
],
'interface' => [
],
'columns' => [
'sys_language_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'language'
],
],
'l18n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_dlf_metadata',
'foreign_table_where' => 'AND tx_dlf_metadata.pid=###CURRENT_PID### AND tx_dlf_metadata.sys_language_uid IN (-1,0) ORDER BY label ASC',
'items' => [
[
'label' => '',
'value' => 0,
],
],
'default' => 0,
],
],
'l18n_diffsource' => [
'config' => [
'type' => 'passthrough',
],
],
'label' => [
'exclude' => 1,
'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_labels.xlf:tx_dlf_metadata.label',
'config' => [
'type' => 'input',
'size' => 30,
'max' => 255,
'required' => true,
'eval' => 'trim',
'default' => '',
],
],
'index_name' => [
'exclude' => 1,
'l10n_mode' => 'exclude',
'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_labels.xlf:tx_dlf_metadata.index_name',
'config' => [
'type' => 'input',
'size' => 30,
'max' => 255,
'required' => true,
'eval' => 'nospace,alphanum_x,uniqueInPid',
'default' => '',
'fieldInformation' => [
'editInProductionWarning' => [
'renderType' => 'editInProductionWarning',
],
],
],
],
[...]
*Affected Versions*
- at least 13.x (tested)
Reviews 2
History 13
-
Gerrit Code Review pushed patch set 1 for main to change 96562 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-09T13:18:14+00:00" > 10/09/26, 13:18 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 96642 <span data-processor="relativetime" data-value="2026-10-12T19:46:08+00:00" > 10/12/26, 19:46 </span>
-
Benni Mack commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-10-12T20:00:11+00:00" > 10/12/26, 20:00 </span>
Applied in changeset commit:61a1b913b05ce86ea80a26ba82b1fb48f480d4dc.