[FOLLOWUP][TASK] Remove support for transForeignTable in TCA 45/50845/2
authorOliver Hader <oliver@typo3.org>
Fri, 2 Dec 2016 09:44:49 +0000 (10:44 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Fri, 2 Dec 2016 10:04:26 +0000 (11:04 +0100)
Resolves: #78191
Releases: master
Change-Id: I944601b8ccd2c2aa5c15bd7473eae5f4246d52a3
Reviewed-on: https://review.typo3.org/50845
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php

index fa03209..eaf0a95 100644 (file)
@@ -57,6 +57,7 @@ class TcaMigration
         $tca = $this->migrateTSconfigSoftReferences($tca);
         $tca = $this->migrateShowIfRteOption($tca);
         $tca = $this->migrateWorkspacesOptions($tca);
+        $tca = $this->migrateTranslationTable($tca);
         // @todo: if showitem/defaultExtras wizards[xy] is migrated to columnsOverrides here, enableByTypeConfig could be dropped
         return $tca;
     }
@@ -872,4 +873,28 @@ class TcaMigration
         }
         return $tca;
     }
+
+    /**
+     * Removes "transForeignTable" and "transOrigPointerTable" which has been
+     * used for tables "pages" and "pages_languages_overlay" in the core only.
+     *
+     * @param array $tca
+     * @return array Migrated TCA
+     */
+    protected function migrateTranslationTable(array $tca)
+    {
+        foreach ($tca as $table => &$tableDefinition) {
+            if (!empty($tableDefinition['ctrl']['transForeignTable'])) {
+                unset($tableDefinition['ctrl']['transForeignTable']);
+                $this->messages[] = 'The TCA setting \'transForeignTable\' was removed '
+                    . 'in TCA ' . $table . '[\'ctrl\'][\'transForeignTable\']';
+            }
+            if (!empty($tableDefinition['ctrl']['transOrigPointerTable'])) {
+                unset($tableDefinition['ctrl']['transOrigPointerTable']);
+                $this->messages[] = 'The TCA setting \'transOrigPointerTable\' was removed '
+                    . 'in TCA ' . $table . '[\'ctrl\'][\'transOrigPointerTable\']';
+            }
+        }
+        return $tca;
+    }
 }
index 44ac224..fbdef39 100644 (file)
@@ -1865,4 +1865,53 @@ class TcaMigrationTest extends UnitTestCase
         $subject = new TcaMigration();
         $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
     }
+
+    /**
+     * @return array
+     */
+    public function migrateTranslationTableDataProvider()
+    {
+        return [
+            'remove transForeignTable' => [
+                [
+                    'aTable' => [
+                        'ctrl' => [
+                            'transForeignTable' => 'pages_language_overlay',
+                        ],
+                    ],
+                ],
+                [
+                    'aTable' => [
+                        'ctrl' => [],
+                    ],
+                ]
+            ],
+            'remove transOrigPointerTable' => [
+                [
+                    'aTable' => [
+                        'ctrl' => [
+                            'transOrigPointerTable' => 'pages',
+                        ],
+                    ],
+                ],
+                [
+                    'aTable' => [
+                        'ctrl' => [],
+                    ],
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @param array $givenConfig
+     * @param array $expectedConfig
+     * @test
+     * @dataProvider migrateTranslationTableDataProvider
+     */
+    public function migrateTranslationTable(array $givenConfig, array $expectedConfig)
+    {
+        $subject = new TcaMigration();
+        $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
+    }
 }