[TASK] Migrate DatabaseRowsUpdateWizard to UpgradeWizardInterface 78/58278/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 14 Sep 2018 14:00:45 +0000 (16:00 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Sat, 15 Sep 2018 15:38:07 +0000 (17:38 +0200)
Resolves: #86200
Related: #86172
Releases: master
Change-Id: I9f6412ed7a6adb8b00f62cbca7476a49bed6985d
Reviewed-on: https://review.typo3.org/58278
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
typo3/sysext/install/Classes/Updates/DatabaseRowsUpdateWizard.php
typo3/sysext/install/ext_localconf.php

index 250ad53..c46a1f8 100644 (file)
@@ -269,7 +269,7 @@ class UpgradeWizardsService
     }
 
     /**
-     * Get list of registered upgrade wizards.
+     * Get list of registered upgrade wizards not marked done.
      *
      * @return array List of upgrade wizards in correct order with detail information
      */
index 094c1b0..345b092 100644 (file)
@@ -40,14 +40,9 @@ use TYPO3\CMS\Install\Updates\RowUpdater\RteLinkSyntaxUpdater;
  * the run process, so if for instance the PHP process runs into a timeout,
  * the job can restart at the position it stopped.
  */
-class DatabaseRowsUpdateWizard extends AbstractUpdate
+class DatabaseRowsUpdateWizard implements UpgradeWizardInterface, RepeatableInterface
 {
     /**
-     * @var string Title of this updater
-     */
-    protected $title = 'Execute database migrations on single rows';
-
-    /**
      * @var array Single classes that may update rows
      */
     protected $rowUpdater = [
@@ -57,24 +52,28 @@ class DatabaseRowsUpdateWizard extends AbstractUpdate
     ];
 
     /**
-     * Checks if an update is needed by looking up in registry if all
-     * registered update row classes are marked as done or not.
-     *
-     * @param string &$description The description for the update
-     * @return bool Whether an update is needed (TRUE) or not (FALSE)
+     * @return string Unique identifier of this updater
      */
-    public function checkForUpdate(&$description)
+    public function getIdentifier(): string
     {
-        $updateNeeded = false;
-        $rowUpdaterNotExecuted = $this->getRowUpdatersToExecute();
-        if (!empty($rowUpdaterNotExecuted)) {
-            $updateNeeded = true;
-        }
-        if (!$updateNeeded) {
-            return false;
-        }
+        return 'databaseRowsUpdateWizard';
+    }
+
+    /**
+     * @return string Title of this updater
+     */
+    public function getTitle(): string
+    {
+        return 'Execute database migrations on single rows';
+    }
 
-        $description = 'Some row updaters have not been executed:';
+    /**
+     * @return string Longer description of this updater
+     */
+    public function getDescription(): string
+    {
+        $rowUpdaterNotExecuted = $this->getRowUpdatersToExecute();
+        $description = 'Row updaters that have not been executed:';
         foreach ($rowUpdaterNotExecuted as $rowUpdateClassName) {
             $rowUpdater = GeneralUtility::makeInstance($rowUpdateClassName);
             if (!$rowUpdater instanceof RowUpdaterInterface) {
@@ -85,20 +84,35 @@ class DatabaseRowsUpdateWizard extends AbstractUpdate
             }
             $description .= LF . $rowUpdater->getTitle();
         }
+        return $description;
+    }
 
-        return $updateNeeded;
+    /**
+     * @return bool True if at least one row updater is not marked done
+     */
+    public function updateNecessary(): bool
+    {
+        return !empty($this->getRowUpdatersToExecute());
+    }
+
+    /**
+     * @return string[] All new fields and tables must exist
+     */
+    public function getPrerequisites(): array
+    {
+        return [
+            DatabaseUpdatedPrerequisite::class
+        ];
     }
 
     /**
      * Performs the configuration update.
      *
-     * @param array &$databaseQueries Queries done in this update - not filled for this updater
-     * @param string &$customMessage Custom message
      * @return bool
      * @throws \Doctrine\DBAL\ConnectionException
      * @throws \Exception
      */
-    public function performUpdate(array &$databaseQueries, &$customMessage)
+    public function executeUpdate(): bool
     {
         $registry = GeneralUtility::makeInstance(Registry::class);
 
index f9c0638..93208bc 100644 (file)
@@ -12,7 +12,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\In
     = \TYPO3\CMS\Install\Updates\StartModuleUpdate::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\FrontendUserImageUpdateWizard::class]
     = \TYPO3\CMS\Install\Updates\FrontendUserImageUpdateWizard::class;
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\DatabaseRowsUpdateWizard::class]
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['databaseRowsUpdateWizard']
     = \TYPO3\CMS\Install\Updates\DatabaseRowsUpdateWizard::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\CommandLineBackendUserRemovalUpdate::class]
     = \TYPO3\CMS\Install\Updates\CommandLineBackendUserRemovalUpdate::class;