[TASK] Move install update flags to system registry 04/46904/6
authorMathias Brodala <mbrodala@pagemachine.de>
Fri, 26 Feb 2016 09:36:39 +0000 (10:36 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 3 Mar 2016 16:18:42 +0000 (17:18 +0100)
This moves the install update (aka "wizards") flags from
LocalConfiguration.php to the system registry and thus
into the database.

Resolves: #72290
Releases: master
Change-Id: Id319fa46d61e862e2429b93aedc7900315526e82
Reviewed-on: https://review.typo3.org/46904
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Configuration/ConfigurationManager.php
typo3/sysext/core/Documentation/Changelog/master/Important-72290-MoveInstallToolUpdateFlagsToSystemRegistry.rst [new file with mode: 0644]
typo3/sysext/install/Classes/Controller/Action/Step/DefaultConfiguration.php
typo3/sysext/install/Classes/Updates/AbstractUpdate.php
typo3/sysext/install/Classes/Updates/WizardDoneToRegistry.php [new file with mode: 0644]
typo3/sysext/install/ext_localconf.php

index 2b2837d..5891183 100644 (file)
@@ -74,7 +74,6 @@ class ConfigurationManager
     protected $whiteListedLocalConfigurationPaths = array(
         'EXT/extConf',
         'EXTCONF',
-        'INSTALL/wizardDone',
         'DB',
         'SYS/caching/cacheConfigurations',
     );
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-72290-MoveInstallToolUpdateFlagsToSystemRegistry.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-72290-MoveInstallToolUpdateFlagsToSystemRegistry.rst
new file mode 100644 (file)
index 0000000..191855e
--- /dev/null
@@ -0,0 +1,10 @@
+=====================================================================
+Important: #72290 - Move install tool update flags to system registry
+=====================================================================
+
+Description
+===========
+
+The flags to mark install tool updates (aka "wizards") as done have been moved from ``LocalConfiguration.php`` to the system registry in the database.
+
+The update can be performed from the install tool.
\ No newline at end of file
index b0ab00d..e0a15c2 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Controller\Action\Step;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\EnableFileService;
 
@@ -110,8 +111,9 @@ For each website you need a TypoScript template on the main page of your website
         // Mark upgrade wizards as done
         $this->loadExtLocalconfDatabaseAndExtTables();
         if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'])) {
+            $registry = GeneralUtility::makeInstance(Registry::class);
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $updateClassName) {
-                $configurationValues['INSTALL/wizardDone/' . $updateClassName] = 1;
+                $registry->set('installUpdate', $updateClassName, 1);
             }
         }
 
index f6f1f7d..4f8549e 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Install\Updates;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Configuration\ConfigurationManager;
+use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Controller\Action\Tool\UpgradeWizard;
 
@@ -197,8 +199,7 @@ abstract class AbstractUpdate
      */
     protected function markWizardAsDone($confValue = 1)
     {
-        GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class)
-            ->setLocalConfigurationValueByPath('INSTALL/wizardDone/' . get_class($this), $confValue);
+        GeneralUtility::makeInstance(Registry::class)->set('installUpdate', get_class($this), $confValue);
     }
 
     /**
@@ -209,13 +210,18 @@ abstract class AbstractUpdate
     protected function isWizardDone()
     {
         $wizardClassName = get_class($this);
-        $done = false;
-        if (
-            isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone'][$wizardClassName])
-            && $GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone'][$wizardClassName]
-        ) {
-            $done = true;
+        $done = GeneralUtility::makeInstance(Registry::class)->get('installUpdate', $wizardClassName, false);
+
+        // Fall back in case the wizard for migration of "wizard done" flags to system registry was not run yet
+        if (!$done) {
+            try {
+                GeneralUtility::makeInstance(ConfigurationManager::class)
+                    ->getLocalConfigurationValueByPath('INSTALL/wizardDone/' . $wizardClassName);
+                $done = true;
+            } catch (\RuntimeException $e) {
+            }
         }
+
         return $done;
     }
 
diff --git a/typo3/sysext/install/Classes/Updates/WizardDoneToRegistry.php b/typo3/sysext/install/Classes/Updates/WizardDoneToRegistry.php
new file mode 100644 (file)
index 0000000..c8a8ff6
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+namespace TYPO3\CMS\Install\Updates;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Configuration\ConfigurationManager;
+use TYPO3\CMS\Core\Registry;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Move "wizard done" flags to system registry
+ */
+class WizardDoneToRegistry extends AbstractUpdate
+{
+    /**
+     * @var string
+     */
+    protected $title = 'Move "wizard done" flags from LocalConfiguration.php to system registry';
+
+    /**
+     * Checks if an update is needed
+     *
+     * @param string &$description The description for the update
+     * @return bool Whether an update is needed (TRUE) or not (FALSE)
+     */
+    public function checkForUpdate(&$description)
+    {
+        $result = false;
+        $description = 'Moves all "wizard done" flags from LocalConfiguration.php to system registry.';
+
+        try {
+            $wizardsDone = GeneralUtility::makeInstance(ConfigurationManager::class)->getLocalConfigurationValueByPath('INSTALL/wizardDone');
+
+            if (!empty($wizardsDone)) {
+                $result = true;
+            }
+        } catch (\RuntimeException $e) {
+        }
+
+        return $result;
+    }
+
+    /**
+     * Performs the accordant updates.
+     *
+     * @param array &$dbQueries Queries done in this update
+     * @param mixed &$customMessages Custom messages
+     * @return bool Whether everything went smoothly or not
+     */
+    public function performUpdate(array &$dbQueries, &$customMessages)
+    {
+        $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
+        $registry = GeneralUtility::makeInstance(Registry::class);
+        $wizardsDone = $configurationManager->getLocalConfigurationValueByPath('INSTALL/wizardDone');
+        $configurationKeysToRemove = [];
+
+        foreach ($wizardsDone as $wizardClassName => $value) {
+            $registry->set('installUpdate', $wizardClassName, $value);
+            $configurationKeysToRemove[] = 'INSTALL/wizardDone/' . $wizardClassName;
+        }
+
+        $configurationKeysToRemove[] = 'INSTALL/wizardDone';
+
+        $configurationManager->removeLocalConfigurationKeysByPath($configurationKeysToRemove);
+
+        $this->markWizardAsDone();
+        return true;
+    }
+}
index 42fbd93..abe1dcc 100644 (file)
@@ -20,5 +20,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\In
     = \TYPO3\CMS\Install\Updates\ExtensionManagerTables::class;
 
 // Add update wizards below this line
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\WizardDoneToRegistry::class]
+    = \TYPO3\CMS\Install\Updates\WizardDoneToRegistry::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdateAboutModule::class]
     = \TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdateAboutModule::class;