[TASK] Deprecate inline localizationMode 50/51650/4
authorOliver Hader <oliver@typo3.org>
Sun, 12 Feb 2017 21:16:26 +0000 (22:16 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Mon, 20 Mar 2017 09:16:24 +0000 (10:16 +0100)
TCA type's inline localizationMode can either be "keep" or "select".
At least "keep" is counter-productive if allowLanguageSynchronization
is enabled. That's why the whole localizationMode behaviour setting
shall be deprecated and ignored in case allowLanguageSynchronization
is enabled for the very same TCA field.

This change does not migrate non-conflicting localizationMode settings
automatically, since this potentially might be breaking and cannot be
done without side-effects. Besides that calls to the static function
BackendUtility::getInlineLocalizationMode() do not trigger a new entry
in the deprectation log since the usage of localizationMode in TCA is
logged already.

Resolves: #79770
Releases: master
Change-Id: Ic2072877d08bb880e9e957d6d31f0527333c2cc5
Reviewed-on: https://review.typo3.org/51650
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php
typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInline.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInlineConfiguration.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-79770-DeprecateInlineLocalizationMode.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php

index 3eb58a9..9c584c0 100644 (file)
@@ -149,6 +149,7 @@ class FormInlineAjaxController extends AbstractFormEngineAjaxController
         // @todo: To my understanding, the below case can't happen: With localizationMode select, lang overlays
         // @todo: of children are only created with the "synchronize" button that will trigger a different ajax action.
         // @todo: The edge case of new page overlay together with localized media field, this code won't kick in either.
+        // @deprecated: IRRE 'localizationMode' is deprecated and will be removed in TYPO3 CMS 9
         /**
         if ($parent['localizationMode'] === 'select' && MathUtility::canBeInterpretedAsInteger($parent['uid'])) {
             $parentRecord = $inlineRelatedRecordResolver->getRecord($parent['table'], $parent['uid']);
index 5a0d95a..51cadac 100644 (file)
@@ -80,6 +80,7 @@ class SingleFieldContainer extends AbstractContainer
             // Return if field should not be rendered in translated records
             || $isOverlay && empty($parameterArray['fieldConf']['l10n_display']) && $parameterArray['fieldConf']['l10n_mode'] === 'exclude'
             // @todo: localizationMode still needs handling!
+            // @deprecated: IRRE 'localizationMode' is deprecated and will be removed in TYPO3 CMS 9
             || $isOverlay && $this->data['localizationMode'] && $this->data['localizationMode'] !== $parameterArray['fieldConf']['l10n_cat']
             || $this->inlineFieldShouldBeSkipped()
         ) {
index 840393a..58a5b50 100644 (file)
@@ -137,6 +137,7 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
         //           ** Localized child overlay exists but default language row does not - this dangling child is a data inconsistency
 
         // Mode was prepared by TcaInlineConfiguration provider
+        // @deprecated: IRRE 'localizationMode' is deprecated and will be removed in TYPO3 CMS 9
         $mode = $result['processedTca']['columns'][$fieldName]['config']['behaviour']['localizationMode'];
         if ($mode === 'none') {
             $connectedUids = [];
index 4a8331e..a5d3e03 100644 (file)
@@ -145,6 +145,7 @@ class TcaInlineConfiguration implements FormDataProviderInterface
         if ($result['defaultLanguageRow'] === null) {
             // Currently handled parent is a localized row if a former provider added the "default" row
             // If handled record is not localized, set localizationMode to 'none' and return
+            // @deprecated: IRRE 'localizationMode' is deprecated and will be removed in TYPO3 CMS 9
             $result['processedTca']['columns'][$fieldName]['config']['behaviour']['localizationMode'] = 'none';
             return $result;
         }
@@ -190,6 +191,7 @@ class TcaInlineConfiguration implements FormDataProviderInterface
             }
         }
 
+        // @deprecated: IRRE 'localizationMode' is deprecated and will be removed in TYPO3 CMS 9
         $result['processedTca']['columns'][$fieldName]['config']['behaviour']['localizationMode'] = $mode;
         return $result;
     }
index fa932a4..001d989 100644 (file)
@@ -668,6 +668,7 @@ class BackendUtility
      * @param string $table The name of the table to lookup in TCA
      * @param mixed $fieldOrConfig The fieldname (string) or the configuration of the field to check (array)
      * @return mixed If table is localizable, the set localizationMode is returned (if property is not set, 'select' is returned by default); if table is not localizable, FALSE is returned
+     * @deprecated: IRRE 'localizationMode' is deprecated and will be removed in TYPO3 CMS 9, migrate to l10n_mode or allowLanguageSynchronization
      */
     public static function getInlineLocalizationMode($table, $fieldOrConfig)
     {
index e199f98..0268d33 100644 (file)
@@ -67,6 +67,7 @@ class TcaMigration
         $tca = $this->migrateTranslationTable($tca);
         $tca = $this->migrateL10nModeDefinitions($tca);
         $tca = $this->migratePageLocalizationDefinitions($tca);
+        $tca = $this->migrateInlineLocalizationMode($tca);
         $tca = $this->migrateRequestUpdate($tca);
         $tca = $this->migrateInputDateTimeToRenderType($tca);
         $tca = $this->migrateWizardEnableByTypeConfigToColumnsOverrides($tca);
@@ -1045,6 +1046,47 @@ class TcaMigration
     }
 
     /**
+     * Removes "localizationMode" set to "keep" if used in combination with
+     * "allowLanguageSynchronization" - in general "localizationMode" is
+     * deprecated since TYPO3 CMS 8 and will be removed in TYPO3 CMS 9.
+     *
+     * @param array $tca
+     * @return array
+     */
+    protected function migrateInlineLocalizationMode(array $tca)
+    {
+        foreach ($tca as $table => &$tableDefinition) {
+            if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
+                continue;
+            }
+            foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) {
+                if (($fieldConfig['config']['type'] ?? null) !== 'inline') {
+                    continue;
+                }
+
+                $inlineLocalizationMode = ($fieldConfig['config']['behaviour']['localizationMode'] ?? null);
+                if ($inlineLocalizationMode === null) {
+                    continue;
+                }
+
+                $allowLanguageSynchronization = ($fieldConfig['config']['behaviour']['allowLanguageSynchronization'] ?? null);
+                if ($inlineLocalizationMode === 'keep' && $allowLanguageSynchronization) {
+                    unset($fieldConfig['config']['behaviour']['localizationMode']);
+                    $this->messages[] = 'The TCA setting \'localizationMode\' is counter-productive '
+                        . ' if being used in combination with \'allowLanguageSynchronization\' and '
+                        . ' thus has been removed from TCA for ' . $table . '[\'columns\']'
+                        . '[\'' . $fieldName . '\'][\'config\'][\'behaviour\'][\'localizationMode\']';
+                } else {
+                    $this->messages[] = 'The TCA setting \'localizationMode\' is deprecated '
+                        . ' and should be removed from TCA for ' . $table . '[\'columns\']'
+                        . '[\'' . $fieldName . '\'][\'config\'][\'behaviour\'][\'localizationMode\']';
+                }
+            }
+        }
+        return $tca;
+    }
+
+    /**
      * Move ['ctrl']['requestUpdate'] to 'onChange => "reload"' of single fields
      *
      * @param array $tca Incoming TCA
index 16227e3..a3f4cdb 100644 (file)
@@ -610,6 +610,7 @@ class ExtensionManagementUtility
                 ],
             ],
             'behaviour' => [
+                // @deprecated: IRRE 'localizationMode' is deprecated and will be removed in TYPO3 CMS 9
                 'localizationMode' => 'select',
                 'localizeChildrenAtParentLocalization' => true,
             ],
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-79770-DeprecateInlineLocalizationMode.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-79770-DeprecateInlineLocalizationMode.rst
new file mode 100644 (file)
index 0000000..fddc534
--- /dev/null
@@ -0,0 +1,35 @@
+.. include:: ../../Includes.txt
+
+=======================================================
+Deprecation: #79770 - Deprecate inline localizationMode
+=======================================================
+
+See :issue:`79770`
+
+Description
+===========
+
+The `localizationMode` for inline relational record editing types is deprecated.
+
+
+Impact
+======
+
+Using `localizationMode` set to `keep` and having `allowLanguageSynchronization` enabled at the same time is counter-productive, since it will deny the synchronization process for the affected field. That's why `localizationMode` is unset only if `allowLanguageSynchronization` is enabled.
+
+
+Affected Installations
+======================
+
+All having `$TCA[<table-name>]['columns'][<field-name>]['config']['behaviour']['localizationMode']` defined for database tables that support translations.
+
+
+Migration
+=========
+
+Remove `$TCA[<table-name>]['columns'][<field-name>]['config']['behaviour']['localizationMode']` definitions and make use of either one of the following
+
+* `$TCA[<table-name>]['columns'][<field-name>]['config']['behaviour']['allowLanguageSynchronization'] = true` if editors can decide whether to provide custom child references or synchronize all references from the language parent record - this comes close to `localizationMode=select` without having the possibility to selectively translate child references
+* `$TCA[<table-name>]['columns'][<field-name>]['l10n_mode'] = 'exclude'` if editors don't have a choice to translate child references - this corresponds to `localizationMode=keep`
+
+.. index:: Backend, TCA
\ No newline at end of file
index 25b19ff..28e98fb 100644 (file)
@@ -2336,6 +2336,119 @@ class TcaMigrationTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @return array
      */
+    public function migrateInlineLocalizationModeDataProvider()
+    {
+        return [
+            'remove counter-productive localizationMode=keep' => [
+                [
+                    'aTable' => [
+                        'columns' => [
+                            'aColumn' => [
+                                'config' => [
+                                    'type' => 'inline',
+                                    'behaviour' => [
+                                        'localizationMode' => 'keep',
+                                        'allowLanguageSynchronization' => true,
+                                    ],
+                                ]
+                            ],
+                        ],
+                    ],
+                ],
+                [
+                    'aTable' => [
+                        'columns' => [
+                            'aColumn' => [
+                                'config' => [
+                                    'type' => 'inline',
+                                    'behaviour' => [
+                                        'allowLanguageSynchronization' => true,
+                                    ],
+                                ],
+                            ],
+                        ],
+                    ],
+                ]
+            ],
+            'keep deprecated localizationMode=keep' => [
+                [
+                    'aTable' => [
+                        'columns' => [
+                            'aColumn' => [
+                                'config' => [
+                                    'type' => 'inline',
+                                    'behaviour' => [
+                                        'localizationMode' => 'keep',
+                                    ],
+                                ],
+                            ],
+                        ],
+                    ],
+                ],
+                [
+                    'aTable' => [
+                        'columns' => [
+                            'aColumn' => [
+                                'config' => [
+                                    'type' => 'inline',
+                                    'behaviour' => [
+                                        'localizationMode' => 'keep',
+                                    ],
+                                ]
+                            ],
+                        ],
+                    ],
+                ]
+            ],
+            'keep deprecated localizationMode=select' => [
+                [
+                    'aTable' => [
+                        'columns' => [
+                            'aColumn' => [
+                                'config' => [
+                                    'type' => 'inline',
+                                    'behaviour' => [
+                                        'localizationMode' => 'select',
+                                    ],
+                                ],
+                            ],
+                        ],
+                    ],
+                ],
+                [
+                    'aTable' => [
+                        'columns' => [
+                            'aColumn' => [
+                                'config' => [
+                                    'type' => 'inline',
+                                    'behaviour' => [
+                                        'localizationMode' => 'select',
+                                    ],
+                                ]
+                            ],
+                        ],
+                    ],
+                ]
+            ],
+        ];
+    }
+
+    /**
+     * @param array $givenConfig
+     * @param array $expectedConfig
+     * @test
+     * @dataProvider migrateInlineLocalizationModeDataProvider
+     */
+    public function migrateInlineLocalizationMode(array $givenConfig, array $expectedConfig)
+    {
+        $subject = new TcaMigration();
+        $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
+        $this->assertNotEmpty($subject->getMessages());
+    }
+
+    /**
+     * @return array
+     */
     public function migrateMovesRequestUpdateCtrlFieldToColumnsDataProvider()
     {
         return [