diff --git a/typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php b/typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php index ce3e238f83be7e63bb5983e8db9819a5cbe42fbe..8761ae062d3d25300e43cfb0045c5bb2e76a7eeb 100644 --- a/typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php +++ b/typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php @@ -39,8 +39,15 @@ class LocalizationStateSelector extends AbstractNode $fieldName = $this->data['fieldName']; $fieldId = StringUtility::getUniqueId('formengine-localization-state-selector-'); $l10nStateFieldName = 'l10n_state'; + + $localizationState = State::fromJSON( + $this->data['tableName'], + $this->data['databaseRow'][$l10nStateFieldName] ?? null + ); + if ( - !isset($this->data['defaultLanguageRow']) + $localizationState === null + || !isset($this->data['defaultLanguageRow']) || !isset($this->data['processedTca']['columns'][$fieldName]['config']['behaviour']['allowLanguageSynchronization']) || !$this->data['processedTca']['columns'][$fieldName]['config']['behaviour']['allowLanguageSynchronization'] ) { @@ -68,11 +75,6 @@ class LocalizationStateSelector extends AbstractNode $fieldValueInParentRow = (string)$this->data['defaultLanguageRow'][$fieldName]; } - $localizationState = State::fromJSON( - $this->data['tableName'], - $this->data['databaseRow'][$l10nStateFieldName] ?? null - ); - $fieldElementName = 'data[' . htmlspecialchars($this->data['tableName']) . ']' . '[' . htmlspecialchars((string)$this->data['databaseRow']['uid']) . ']' . '[' . htmlspecialchars($l10nStateFieldName) . ']' diff --git a/typo3/sysext/core/Classes/Configuration/Tca/TcaMigration.php b/typo3/sysext/core/Classes/Configuration/Tca/TcaMigration.php index 529f8e3d66b4443b8c827fd2e000cad89ffa00f2..be89b7d730500718825f039e98fec77f89f325b3 100644 --- a/typo3/sysext/core/Classes/Configuration/Tca/TcaMigration.php +++ b/typo3/sysext/core/Classes/Configuration/Tca/TcaMigration.php @@ -87,6 +87,7 @@ class TcaMigration $tca = $this->removeMmInsertFields($tca); $tca = $this->removeMmHasUidField($tca); $tca = $this->migrateT3EditorToCodeEditor($tca); + $tca = $this->removeAllowLanguageSynchronizationFromColumnsOverrides($tca); return $tca; } @@ -1472,4 +1473,29 @@ class TcaMigration } return $tca; } + + /** + * Setting "allowLanguageSynchronization" for columns via columnsOverride is currently not supported + * see Localization\State and therefore leads to an exception in the LocalizationStateSelector wizard. + * Therefore, the setting is removed for now and the integrator is informed accordingly. + */ + protected function removeAllowLanguageSynchronizationFromColumnsOverrides(array $tca): array + { + foreach ($tca as $table => $tableDefinition) { + if (!is_array($tableDefinition['types'] ?? false)) { + continue; + } + foreach ($tableDefinition['types'] ?? [] as $typeName => $typeConfig) { + foreach ($typeConfig['columnsOverrides'] ?? [] as $columnOverride => $columnOverrideConfig) { + if (isset($columnOverrideConfig['config']['behaviour']['allowLanguageSynchronization'])) { + unset($tca[$table]['types'][$typeName]['columnsOverrides'][$columnOverride]['config']['behaviour']['allowLanguageSynchronization']); + $this->messages[] = 'The TCA columns override of column \'' . $columnOverride . '\' for type \'' . $typeName . '\' ' + . 'of table \'' . $table . '\' sets \'[behaviour][allowLanguageSynchronization]\'. Setting ' + . 'this option in \'columnsOverrides\' is currently not supported. Please adjust your TCA accordingly.'; + } + } + } + } + return $tca; + } } diff --git a/typo3/sysext/core/Documentation/Changelog/12.4.x/Important-104693-SettingAllowLanguageSynchronizationViaColumnsOverrides.rst b/typo3/sysext/core/Documentation/Changelog/12.4.x/Important-104693-SettingAllowLanguageSynchronizationViaColumnsOverrides.rst new file mode 100644 index 0000000000000000000000000000000000000000..c1948065c7397903db6af85e3fa3fa059b98483b --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/12.4.x/Important-104693-SettingAllowLanguageSynchronizationViaColumnsOverrides.rst @@ -0,0 +1,53 @@ +.. include:: /Includes.rst.txt + +.. _important-104693-1725960199: + +============================================================================== +Important: #104693 - Setting allowLanguageSynchronization via columnsOverrides +============================================================================== + +See :issue:`104693` + +Description +=========== + +Setting the TCA option :php:`allowLanguageSynchronization` for a specific +column in a record type via :php:`columnsOverrides` is currently not supported +by TYPO3 and therefore might lead to exceptions in the corresponding field wizard +(:php:`LocalizationStateSelector`). To mitigate this, the option is now +automatically removed from the TCA configuration via a TCA migration. A +corresponding deprecation log entry is added to inform integrators about +the necessary code adjustments. + +Migration +========= + +Remove the :php:`allowLanguageSynchronization` option from :php:`columnsOverrides` +for now. + +.. code-block:: php + + // Before + 'types' => [ + 'text' => [ + 'showitem' => 'header', + 'columnsOverrides' => [ + 'header' => [ + 'config' => [ + 'behaviour' => [ + 'allowLanguageSynchronization' => true + ], + ], + ], + ], + ], + ], + + // After + 'types' => [ + 'text' => [ + 'showitem' => 'header', + ], + ], + +.. index:: Backend, TCA, ext:backend diff --git a/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaMigrationTest.php b/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaMigrationTest.php index 4fa832f0b6289ab5e2f1457e100aa1efc321b83f..2eec8ae4ead392822a7b1ef61703181146bfc724 100644 --- a/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaMigrationTest.php +++ b/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaMigrationTest.php @@ -3523,4 +3523,79 @@ final class TcaMigrationTest extends UnitTestCase ]; self::assertSame($expected, (new TcaMigration())->migrate($input)); } + + #[Test] + public function removeAllowLanguageSynchronizationFromColumnsOverrides(): void + { + $input = [ + 'aTable' => [ + 'columns' => [ + 'aColumn' => [ + 'config' => [ + 'type' => 'text', + 'config' => [ + 'behaviour' => [ + 'allowLanguageSynchronization' => true, + ], + ], + ], + ], + 'bColumn' => [ + 'config' => [ + 'type' => 'text', + ], + ], + ], + 'types' => [ + 'aType' => [ + 'showitem' => 'bColumn', + 'columnsOverrides' => [ + 'bColumn' => [ + 'config' => [ + 'behaviour' => [ + 'allowLanguageSynchronization' => true, + ], + ], + ], + ], + ], + ], + ], + ]; + $expected = [ + 'aTable' => [ + 'columns' => [ + 'aColumn' => [ + 'config' => [ + 'type' => 'text', + 'config' => [ + 'behaviour' => [ + 'allowLanguageSynchronization' => true, + ], + ], + ], + ], + 'bColumn' => [ + 'config' => [ + 'type' => 'text', + ], + ], + ], + 'types' => [ + 'aType' => [ + 'showitem' => 'bColumn', + 'columnsOverrides' => [ + 'bColumn' => [ + 'config' => [ + 'behaviour' => [ + ], + ], + ], + ], + ], + ], + ], + ]; + self::assertSame($expected, (new TcaMigration())->migrate($input)); + } }