From 64af7df554e0fc33fcedf01416eef3444556118b Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Tue, 17 May 2022 13:54:03 +0200 Subject: [PATCH] [FEATURE] DataStructure Update - Create v11LTS updates from TcaMigration Related: #372 Release: 8.0.0 --- .../Update/DataStructureV11Controller.php | 202 ++++++++++++++++++ .../Update/DataStructureV11/StepFinal.html | 33 +++ .../Update/DataStructureV11/StepStart.html | 23 ++ .../Backend/ControlCenter/Update/Info.html | 2 +- ext_tables.php | 1 + 5 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 Classes/Controller/Backend/ControlCenter/Update/DataStructureV11Controller.php create mode 100644 Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepFinal.html create mode 100644 Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepStart.html diff --git a/Classes/Controller/Backend/ControlCenter/Update/DataStructureV11Controller.php b/Classes/Controller/Backend/ControlCenter/Update/DataStructureV11Controller.php new file mode 100644 index 000000000..16be2810b --- /dev/null +++ b/Classes/Controller/Backend/ControlCenter/Update/DataStructureV11Controller.php @@ -0,0 +1,202 @@ + + */ +class DataStructureV11Controller extends AbstractUpdateController +{ + protected $errors = []; + + protected function stepStartAction() + { + } + + protected function stepFinalAction() + { + /** @var DataStructureUpdateHandler */ + $handler = GeneralUtility::makeInstance(DataStructureUpdateHandler::class); + $count = $handler->updateAllDs( + [], + [ + [$this, 'migrateColumnsConfig'], + [$this, 'migrateLocalizeChildrenAtParentLocalization'], + [$this, 'removeEnableMultiSelectFilterTextfieldConfiguration'], + [$this, 'migrateSpecialLanguagesToTcaTypeLanguage'], + [$this, 'removeShowRemovedLocalizationRecords'], + [$this, 'migrateFileFolderConfiguration'], + [$this, 'migrateLevelLinksPosition'], + [$this, 'migrateRootUidToStartingPoints'], + ] + ); + + $this->view->assignMultiple([ + 'countStatic' => $countStatic, + 'count' => $count, + 'errors' => $this->errors, + ]); + } + + /** + * Find columns fields that don't have a 'config' section at all, add + * ['config']['type'] = 'none'; for those to enforce config + */ + public function migrateColumnsConfig(array &$element): bool + { + $changed = false; + if ((!isset($element['TCEforms']['config']) || !is_array($element['TCEforms']['config'])) && !isset($element['TCEforms']['type'])) { + $element['TCEforms']['config'] = [ + 'type' => 'none', + ]; + $changed = true; + } + return $changed; + } + + /** + * Option $TCA[$table]['columns'][$columnName]['config']['behaviour']['localizeChildrenAtParentLocalization'] + * is always on, so this option can be removed. + */ + public function migrateLocalizeChildrenAtParentLocalization(array &$element): bool + { + $changed = false; + if (isset($element['TCEforms']['config']['behaviour']['localizeChildrenAtParentLocalization'])) { + unset($element['TCEforms']['config']['behaviour']['localizeChildrenAtParentLocalization']); + $changed = true; + } + return $changed; + } + + /** + * Removes configuration removeEnableMultiSelectFilterTextfield + */ + public function removeEnableMultiSelectFilterTextfieldConfiguration(array &$element): bool + { + $changed = false; + if (isset($element['TCEforms']['config']['enableMultiSelectFilterTextfield'])) { + unset($element['TCEforms']['config']['enableMultiSelectFilterTextfield']); + $changed = true; + } + return $changed; + } + + /** + * Replaces $TCA[$mytable][columns][field][config][special] = 'languages' with + * $TCA[$mytable][columns][field][config][type] = 'language' + */ + public function migrateSpecialLanguagesToTcaTypeLanguage(array &$element): bool + { + $changed = false; + if ((string)($element['TCEforms']['config']['type']) === 'select' + && (string)($element['TCEforms']['config']['special']) === 'languages' + ) { + $element['TCEforms']['config'] = [ + 'type' => 'language', + ]; + $changed = true; + } + return $changed; + } + + public function removeShowRemovedLocalizationRecords(array &$element): bool + { + $changed = false; + if ((string)($element['TCEforms']['config']['type']) === 'inline' + && isset($element['TCEforms']['config']['appearance']['showRemovedLocalizationRecords']) + ) { + unset($element['TCEforms']['config']['appearance']['showRemovedLocalizationRecords']); + $changed = true; + } + return $changed; + } + + /** + * Moves the "fileFolder" configuration of TCA columns type=select + * into sub array "fileFolderConfig", while renaming those options. + */ + public function migrateFileFolderConfiguration(array &$element): bool + { + $changed = false; + if ((string)($element['TCEforms']['config']['type']) === 'select' + && isset($element['TCEforms']['config']['fileFolder']) + ) { + $element['TCEforms']['config']['fileFolderConfig'] = [ + 'folder' => $element['TCEforms']['config']['fileFolder'], + ]; + unset($element['TCEforms']['config']['fileFolder']); + if (isset($element['TCEforms']['config']['fileFolder_extList'])) { + $element['TCEforms']['config']['fileFolderConfig']['allowedExtensions'] = $element['TCEforms']['config']['fileFolder_extList']; + unset($element['TCEforms']['config']['fileFolder_extList']); + } + if (isset($element['TCEforms']['config']['fileFolder_recursions'])) { + $element['TCEforms']['config']['fileFolderConfig']['depth'] = $element['TCEforms']['config']['fileFolder_recursions']; + unset($element['TCEforms']['config']['fileFolder_recursions']); + } + $changed = true; + } + + return $changed; + } + + /** + * The [appearance][levelLinksPosition] option can be used + * to select the position of the level links. This option + * was previously misused to disable all those links by + * setting it to "none". Since all of those links can be + * disabled by a dedicated option, e.g. showNewRecordLink, + * this wizard sets those options to false and unsets the + * invalid levelLinksPosition value. + */ + public function migrateLevelLinksPosition(array &$element): bool + { + $changed = false; + if ((string)($element['TCEforms']['config']['type']) === 'inline' + && (string)($element['TCEforms']['config']['appearance']['levelLinksPosition']) === 'none' + ) { + unset($element['TCEforms']['config']['appearance']['levelLinksPosition']); + $element['TCEforms']['config']['appearance']['showAllLocalizationLink'] = false; + $element['TCEforms']['config']['appearance']['showSynchronizationLink'] = false; + $element['TCEforms']['config']['appearance']['showNewRecordLink'] = false; + $changed = true; + } + + return $changed; + } + + /** + * If a column has [treeConfig][rootUid] defined, migrate to [treeConfig][startingPoints] on the same level. + */ + public function migrateRootUidToStartingPoints(array &$element): bool + { + $changed = false; + if ((int)($element['TCEforms']['config']['treeConfig']['rootUid'] ?? 0) !== 0 + && in_array((string)($element['TCEforms']['config']['type']), ['select', 'category'], true) + ) { + $element['TCEforms']['config']['treeConfig']['startingPoints'] = (string)(int)($element['TCEforms']['config']['treeConfig']['rootUid']); + unset($element['TCEforms']['config']['treeConfig']['rootUid']); + $changed = true; + } + + return $changed; + } +} diff --git a/Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepFinal.html b/Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepFinal.html new file mode 100644 index 000000000..dee28aa86 --- /dev/null +++ b/Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepFinal.html @@ -0,0 +1,33 @@ +{namespace core=TYPO3\CMS\Core\ViewHelpers} + +
+

Update DataStructure for usage with TYPO3 v11 LTS

+

Final

+ + + +
    + +
  • {validationError}
  • +
    +
+
+
+ + +

All done, you can now return to TV+ Update Script collection

+
+ +
+
+ + Back to TV+ Update Script collection + +
+
+
+
+
+
+ +
diff --git a/Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepStart.html b/Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepStart.html new file mode 100644 index 000000000..849efc72c --- /dev/null +++ b/Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepStart.html @@ -0,0 +1,23 @@ +{namespace core=TYPO3\CMS\Core\ViewHelpers} + +
+

Update DataStructure for usage with TYPO3 v11 LTS

+ Please backup your database/files before running any of the update scripts! + +

This script will update all DataStructures, which are in TemplaVoilà! Plus places, to be useable with TYPO3 v8 LTS. They may not backward compatible afterwards.

+ +
+
+ + Back to TV+ Update Script collection + +
+
+
+
+ + Run Update DataStructure from TYPO3 v10 LTS to v11 LTS (Version: 1.0.0) + +
+
+
diff --git a/Resources/Private/Templates/Backend/ControlCenter/Update/Info.html b/Resources/Private/Templates/Backend/ControlCenter/Update/Info.html index f38deddcc..0c7715ffb 100644 --- a/Resources/Private/Templates/Backend/ControlCenter/Update/Info.html +++ b/Resources/Private/Templates/Backend/ControlCenter/Update/Info.html @@ -96,7 +96,7 @@

Please select an update script

- Update DataStructure from TYPO3 v10 LTS to v11 LTS (Version: 0.0.0) + Update DataStructure from TYPO3 v10 LTS to v11 LTS (Version: 1.0.0) diff --git a/ext_tables.php b/ext_tables.php index e1ac675b0..d6e744e5b 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -53,6 +53,7 @@ $classPrefixForRegisterModule . 'Backend\ControlCenter\Update' . $classPostfixForRegisterModule => 'info', $classPrefixForRegisterModule . 'Backend\ControlCenter\Update\TemplaVoilaPlus8' . $classPostfixForRegisterModule => 'stepStart,step1,step2,step3,step3NewExtension,step3ExistingExtension,step4,step5,stepFinal', $classPrefixForRegisterModule . 'Backend\ControlCenter\Update\DataStructureV8' . $classPostfixForRegisterModule => 'stepStart,stepFinal', + $classPrefixForRegisterModule . 'Backend\ControlCenter\Update\DataStructureV11' . $classPostfixForRegisterModule => 'stepStart,stepFinal', ], [ 'access' => 'user,group',