[BUGFIX] Catch exception in Upgrade Wizard 69/50469/5
authorFrank Naegler <frank.naegler@typo3.org>
Tue, 1 Nov 2016 10:09:46 +0000 (11:09 +0100)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Tue, 1 Nov 2016 11:08:57 +0000 (12:08 +0100)
Catch any StatementException and create an ErrorStatus
message containing the exception message.

Resolves: #78529
Related: #78235
Releases: master
Change-Id: I404976856a02f974fd7348dbaf019d21398a0a72
Reviewed-on: https://review.typo3.org/50469
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
typo3/sysext/install/Classes/Controller/Action/Tool/UpgradeWizard.php

index 8b9a0c5..34d6edf 100644 (file)
@@ -15,11 +15,13 @@ namespace TYPO3\CMS\Install\Controller\Action\Tool;
  */
 
 use TYPO3\CMS\Core\Cache\DatabaseSchemaService;
+use TYPO3\CMS\Core\Database\Schema\Exception\StatementException;
 use TYPO3\CMS\Core\Database\Schema\SchemaMigrator;
 use TYPO3\CMS\Core\Database\Schema\SqlReader;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\VersionNumberUtility;
 use TYPO3\CMS\Install\Controller\Action;
+use TYPO3\CMS\Install\Status\ErrorStatus;
 use TYPO3\CMS\Install\Updates\AbstractUpdate;
 
 /**
@@ -48,34 +50,42 @@ class UpgradeWizard extends Action\AbstractAction
             $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] = [];
         }
 
-        // To make sure DatabaseCharsetUpdate and initialUpdateDatabaseSchema are first wizards, they are added here instead of ext_localconf.php
-        $databaseCharsetUpdateObject = $this->getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\DatabaseCharsetUpdate::class, 'databaseCharsetUpdate');
-        if ($databaseCharsetUpdateObject->shouldRenderWizard()) {
-            $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] = array_merge(
-                ['databaseCharsetUpdate' => \TYPO3\CMS\Install\Updates\DatabaseCharsetUpdate::class],
-                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']
-            );
-        }
-        $initialUpdateDatabaseSchemaUpdateObject = $this->getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\InitialDatabaseSchemaUpdate::class, 'initialUpdateDatabaseSchema');
-        if ($initialUpdateDatabaseSchemaUpdateObject->shouldRenderWizard()) {
-            $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] = array_merge(
-                ['initialUpdateDatabaseSchema' => \TYPO3\CMS\Install\Updates\InitialDatabaseSchemaUpdate::class],
-                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']
-            );
-            $this->needsInitialUpdateDatabaseSchema = true;
-        }
+        $actionMessages = [];
+
+        try {
+            // To make sure DatabaseCharsetUpdate and initialUpdateDatabaseSchema are first wizards, they are added here instead of ext_localconf.php
+            $databaseCharsetUpdateObject = $this->getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\DatabaseCharsetUpdate::class, 'databaseCharsetUpdate');
+            if ($databaseCharsetUpdateObject->shouldRenderWizard()) {
+                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] = array_merge(
+                    ['databaseCharsetUpdate' => \TYPO3\CMS\Install\Updates\DatabaseCharsetUpdate::class],
+                    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']
+                );
+            }
+            $initialUpdateDatabaseSchemaUpdateObject = $this->getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\InitialDatabaseSchemaUpdate::class, 'initialUpdateDatabaseSchema');
+            if ($initialUpdateDatabaseSchemaUpdateObject->shouldRenderWizard()) {
+                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] = array_merge(
+                    ['initialUpdateDatabaseSchema' => \TYPO3\CMS\Install\Updates\InitialDatabaseSchemaUpdate::class],
+                    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']
+                );
+                $this->needsInitialUpdateDatabaseSchema = true;
+            }
 
-        // To make sure finalUpdateDatabaseSchema is last wizard, it is added here instead of ext_localconf.php
-        $finalUpdateDatabaseSchemaUpdateObject = $this->getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\FinalDatabaseSchemaUpdate::class, 'finalUpdateDatabaseSchema');
-        if ($finalUpdateDatabaseSchemaUpdateObject->shouldRenderWizard()) {
-            $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['finalUpdateDatabaseSchema'] = \TYPO3\CMS\Install\Updates\FinalDatabaseSchemaUpdate::class;
+            // To make sure finalUpdateDatabaseSchema is last wizard, it is added here instead of ext_localconf.php
+            $finalUpdateDatabaseSchemaUpdateObject = $this->getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\FinalDatabaseSchemaUpdate::class, 'finalUpdateDatabaseSchema');
+            if ($finalUpdateDatabaseSchemaUpdateObject->shouldRenderWizard()) {
+                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['finalUpdateDatabaseSchema'] = \TYPO3\CMS\Install\Updates\FinalDatabaseSchemaUpdate::class;
+            }
+        } catch (StatementException $exception) {
+            /** @var $message \TYPO3\CMS\Install\Status\StatusInterface */
+            $message = GeneralUtility::makeInstance(ErrorStatus::class);
+            $message->setTitle('SQL error');
+            $message->setMessage($exception->getMessage());
+            $actionMessages[] = $message;
         }
 
         // Perform silent cache framework table upgrade
         $this->silentCacheFrameworkTableSchemaMigration();
 
-        $actionMessages = [];
-
         if (isset($this->postValues['set']['getUserInput'])) {
             $actionMessages[] = $this->getUserInputForUpdate();
             $this->view->assign('updateAction', 'getUserInput');