From 1211ada46f49d1a8e9f185e32091d61fd3c4b0f9 Mon Sep 17 00:00:00 2001 From: Frank Naegler Date: Tue, 1 Nov 2016 11:09:46 +0100 Subject: [PATCH] [BUGFIX] Catch exception in Upgrade Wizard 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 Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn Reviewed-by: Philipp Gampe Tested-by: Philipp Gampe --- .../Controller/Action/Tool/UpgradeWizard.php | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/typo3/sysext/install/Classes/Controller/Action/Tool/UpgradeWizard.php b/typo3/sysext/install/Classes/Controller/Action/Tool/UpgradeWizard.php index 8b9a0c5eedd6..34d6edf43195 100644 --- a/typo3/sysext/install/Classes/Controller/Action/Tool/UpgradeWizard.php +++ b/typo3/sysext/install/Classes/Controller/Action/Tool/UpgradeWizard.php @@ -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'); -- 2.20.1