From 1af5fc70555fc7d22bec2a95e645c0915d549139 Mon Sep 17 00:00:00 2001 From: Simon Schaufelberger Date: Thu, 18 Apr 2024 13:44:17 +0200 Subject: [PATCH] [BUGFIX] Skip checkboxes that have a migrated label key Resolves: #4238 --- .../v5/SimplifyCheckboxItemsTCARector.php | 6 ++++ .../Fixture/bug_4238.php.inc | 34 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/Rector/v11/v5/SimplifyCheckboxItemsTCARector/Fixture/bug_4238.php.inc diff --git a/rules/TYPO311/v5/SimplifyCheckboxItemsTCARector.php b/rules/TYPO311/v5/SimplifyCheckboxItemsTCARector.php index 22bf499d7..6233191f4 100644 --- a/rules/TYPO311/v5/SimplifyCheckboxItemsTCARector.php +++ b/rules/TYPO311/v5/SimplifyCheckboxItemsTCARector.php @@ -136,6 +136,12 @@ protected function refactorColumn(Expr $columnName, Expr $columnTca): void return; } + $labelKeyArrayItem = $this->extractArrayItemByKey($firstItemsArray, 'label'); + if ($labelKeyArrayItem instanceof ArrayItem) { + // Skip migrated items which have a "label" key that comes from MigrateItemsIndexedKeysToAssociativeRector. + return; + } + // Remove the whole items array $this->removeArrayItemFromArrayByKey($configArray, 'items'); } diff --git a/tests/Rector/v11/v5/SimplifyCheckboxItemsTCARector/Fixture/bug_4238.php.inc b/tests/Rector/v11/v5/SimplifyCheckboxItemsTCARector/Fixture/bug_4238.php.inc new file mode 100644 index 000000000..c73ca0ed2 --- /dev/null +++ b/tests/Rector/v11/v5/SimplifyCheckboxItemsTCARector/Fixture/bug_4238.php.inc @@ -0,0 +1,34 @@ + [], + 'columns' => [ + 'show_canonical' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'show_canonical', + 'config' => [ + 'type' => 'check', + 'renderType' => 'checkboxToggle', + 'invertStateDisplay' => '1', + 'items' => [ + ['label' => ''], + ], + ], + ], + 'no_archive' => [ + 'exclude' => 1, + 'l10n_mode' => 'exclude', + 'label' => 'no_archive', + 'config' => [ + 'type' => 'check', + 'renderType' => 'checkboxToggle', + 'items' => [ + ['label' => ''], + ], + ], + ], + ], +];