From 6449b06b0e60727f3fbdb84895eb43bbf715d7f7 Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Wed, 30 Jun 2021 12:16:15 +0200
Subject: [PATCH] [TASK] Add strict comparison and extend tests for
 TcaMigaration

Resolves: #94442
Relates: #94441
Releases: master
Change-Id: Iaebd23d0031917c5c5c121c4123cf24304c47169
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69669
Tested-by: core-ci <typo3@b13.com>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
---
 .../core/Classes/Migrations/TcaMigration.php  |  6 +--
 .../Unit/Migrations/TcaMigrationTest.php      | 48 ++++++++++++++++++-
 2 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/core/Classes/Migrations/TcaMigration.php b/typo3/sysext/core/Classes/Migrations/TcaMigration.php
index 0177020137b0..c0e6adb1e8c5 100644
--- a/typo3/sysext/core/Classes/Migrations/TcaMigration.php
+++ b/typo3/sysext/core/Classes/Migrations/TcaMigration.php
@@ -422,14 +422,14 @@ class TcaMigration
                 continue;
             }
             foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) {
-                if ((string)($fieldConfig['config']['type'] ?? '') != 'inline'
+                if ((string)($fieldConfig['config']['type'] ?? '') !== 'inline'
                     || !isset($fieldConfig['config']['appearance']['showRemovedLocalizationRecords'])
                 ) {
                     continue;
                 }
                 $this->messages[] = 'The TCA field \'' . $fieldName . '\' of table \'' . $table . '\' is '
-                    . 'defined as type \'inline\' with the \'appearance.showRemovedLocalizationRecords\' option. This is not '
-                    . 'evaluated anymore. There is no replacement and should therefore be removed.';
+                    . 'defined as type \'inline\' with the \'appearance.showRemovedLocalizationRecords\' option set. '
+                    . 'As this option is not evaluated anymore and no replacement exists, it should be removed from TCA.';
                 unset($fieldConfig['config']['appearance']['showRemovedLocalizationRecords']);
             }
         }
diff --git a/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php b/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php
index 984879e75431..89a830019ed1 100644
--- a/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php
+++ b/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php
@@ -821,7 +821,31 @@ class TcaMigrationTest extends UnitTestCase
                         'config' => [
                             'type' => 'inline',
                             'appearance' => [
-                                'showRemovedLocalizationRecords' => 1
+                                'showRemovedLocalizationRecords' => true
+                            ]
+                        ]
+                    ]
+                ]
+            ],
+            'bTable' => [
+                'columns' => [
+                    'inlineField' => [
+                        'config' => [
+                            'type' => 'inline',
+                            'appearance' => [
+                                'showRemovedLocalizationRecords' => false
+                            ]
+                        ]
+                    ]
+                ]
+            ],
+            'cTable' => [
+                'columns' => [
+                    'someField' => [
+                        'config' => [
+                            'type' => 'select',
+                            'appearance' => [
+                                'showRemovedLocalizationRecords' => true
                             ]
                         ]
                     ]
@@ -840,6 +864,28 @@ class TcaMigrationTest extends UnitTestCase
                     ]
                 ]
             ],
+            'bTable' => [
+                'columns' => [
+                    'inlineField' => [
+                        'config' => [
+                            'type' => 'inline',
+                            'appearance' => []
+                        ]
+                    ]
+                ]
+            ],
+            'cTable' => [
+                'columns' => [
+                    'someField' => [
+                        'config' => [
+                            'type' => 'select',
+                            'appearance' => [
+                                'showRemovedLocalizationRecords' => true
+                            ]
+                        ]
+                    ]
+                ]
+            ],
         ];
 
         $subject = new TcaMigration();
-- 
GitLab