[BUGFIX] Add silent config upgrader for upgrade wizard settings 51/26451/5
authorMarkus Klein <klein.t3@mfc-linz.at>
Mon, 16 Dec 2013 15:49:20 +0000 (16:49 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 2 Feb 2014 21:00:35 +0000 (22:00 +0100)
Add a migration function to the SilentConfigurationUpgradeService which
takes care of migrating the old class names used for the Install Tool
Upgrade Wizard's information storage to the new (namespaced) class names.

Resolves: #54457
Releases: 6.2
Change-Id: Ib6edb9ec3a8a1dc4873eb38e9a08bc8107db31bb
Reviewed-on: https://review.typo3.org/26451
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/cms/ext_tables.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php

index c8bb323..f1deafd 100755 (executable)
@@ -26,7 +26,7 @@ if (!function_exists('user_sortPluginList')) {
 // keep old code (pre-FAL) for installations that haven't upgraded yet. please remove this code in TYPO3 7.0
 // @deprecated since TYPO3 6.0, please remove in TYPO3 7.0
 // existing installation - and files are merged, nothing to do
-if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard']) || !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard'], 'tt_content:image')) && !\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('6.0')) {
+if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard']) || !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard'], 'tt_content:image')) && !\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('6.0')) {
        \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('This installation hasn\'t been migrated to FAL for the field $TCA[tt_content][columns][image] yet. Please do so before TYPO3 v7.');
        // Existing installation and no upgrade wizard was executed - and files haven't been merged: use the old code
        $GLOBALS['TCA']['tt_content']['columns']['image']['config'] = array(
@@ -43,7 +43,7 @@ if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Upd
        );
 }
 
-if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard']) || !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard'], 'tt_content:media')) && !\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('6.0')) {
+if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard']) || !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard'], 'tt_content:media')) && !\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('6.0')) {
        \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('This installation hasn\'t been migrated to FAL for the field $TCA[tt_content][columns][media] yet. Please do so before TYPO3 v7.');
        // Existing installation and no upgrade wizard was executed - and files haven't been merged: use the old code
        $GLOBALS['TCA']['tt_content']['columns']['media']['config'] = array(
@@ -64,7 +64,7 @@ if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Upd
 // Keep old code (pre-FAL) for installations that haven't upgraded yet.
 // @deprecated since TYPO3 6.0, please remove at earliest in TYPO3 6.2
 // existing installation - and files are merged, nothing to do
-if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard']) || !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard'], 'pages_language_overlay:media')) && !\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('6.0')) {
+if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard']) || !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard'], 'pages_language_overlay:media')) && !\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('6.0')) {
        \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('This installation hasn\'t been migrated to FAL for the field $TCA[pages_language_overlay][columns][media] yet. Please do so before TYPO3 v7.');
        // Existing installation and no upgrade wizard was executed - and files haven't been merged: use the old code
        $GLOBALS['TCA']['pages_language_overlay']['columns']['media']['config'] = array(
index 826e4d3..f62e398 100644 (file)
@@ -127,6 +127,7 @@ class SilentConfigurationUpgradeService {
                $this->generateEncryptionKeyIfNeeded();
                $this->configureBackendLoginSecurity();
                $this->configureSaltedPasswords();
+               $this->migrateOldInstallWizardDoneSettingsToNewClassNames();
                $this->setProxyAuthScheme();
                $this->disableImageMagickAndGdlibIfImageProcessingIsDisabled();
                $this->disableImageMagickDetailSettingsIfImageMagickIsDisabled();
@@ -447,6 +448,71 @@ class SilentConfigurationUpgradeService {
                }
        }
 
+       /**
+        * Migrate old Install Tool Wizard "done"-settings to new class names
+        * this happens usually when an existing 6.0/6.1 has called the TceformsUpdateWizard wizard
+        * and has written Tx_Install_Updates_File_TceformsUpdateWizard in TYPO3's LocalConfiguration.php
+        *
+        * @return void
+        */
+       protected function migrateOldInstallWizardDoneSettingsToNewClassNames() {
+               $classNamesToConvert = array();
+               $localConfiguration = $this->configurationManager->getLocalConfiguration();
+               // check for wizards that have been run already and don't start with TYPO3...
+               if (isset($localConfiguration['INSTALL']['wizardDone']) && is_array($localConfiguration['INSTALL']['wizardDone'])) {
+                       $classNames = array_keys($localConfiguration['INSTALL']['wizardDone']);
+                       foreach ($classNames as $className) {
+                               if (!GeneralUtility::isFirstPartOfStr($className, 'TYPO3')) {
+                                       $classNamesToConvert[] = $className;
+                               }
+                       }
+               }
+               if (!count($classNamesToConvert)) {
+                       return;
+               }
+
+               $migratedClassesMapping = array(
+                       'Tx_Install_Updates_File_TceformsUpdateWizard' => 'TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard'
+               );
+
+               $migratedSettings = array();
+               $settingsToRemove = array();
+               foreach ($classNamesToConvert as $oldClassName) {
+                       if (isset($migratedClassesMapping[$oldClassName])) {
+                               $newClassName = $migratedClassesMapping[$oldClassName];
+                       } else {
+                               continue;
+                       }
+                       $oldValue = NULL;
+                       $newValue = NULL;
+                       try {
+                               $oldValue = $this->configurationManager->getLocalConfigurationValueByPath('INSTALL/wizardDone/' . $oldClassName);
+                       } catch (\RuntimeException $e) {
+                               // The old configuration does not exist
+                               continue;
+                       }
+                       try {
+                               $newValue = $this->configurationManager->getLocalConfigurationValueByPath('INSTALL/wizardDone/' . $newClassName);
+                       } catch (\RuntimeException $e) {
+                               // The new configuration does not exist yet
+                       }
+                       if ($newValue === NULL) {
+                               // Migrate the old configuration to the new one
+                               $migratedSettings['INSTALL/wizardDone/' . $newClassName] = $oldValue;
+                       }
+                       $settingsToRemove[] = 'INSTALL/wizardDone/' . $oldClassName;
+
+               }
+
+               if (count($migratedSettings)) {
+                       $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($migratedSettings);
+               }
+               $this->configurationManager->removeLocalConfigurationKeysByPath($settingsToRemove);
+               if (count($migratedSettings) || count($settingsToRemove)) {
+                       $this->throwRedirectException();
+               }
+       }
+
        /**
         * Throw exception after configuration change to trigger a redirect.
         *