[BUGFIX] Prevent crash in Install Tool and EM with invalid ext_tables.sql 80/50180/5
authorXavier Perseguers <xavier@typo3.org>
Tue, 11 Oct 2016 07:54:22 +0000 (09:54 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Thu, 13 Oct 2016 14:04:29 +0000 (16:04 +0200)
If a parsing exception is thrown, this exception is now catched and the
error message is being displayed as a flash message along with
contextual information.

Change-Id: Idb7749d9c6fbde3758829938a77067abbad9f068
Resolves: #78235
Releases: master
Reviewed-on: https://review.typo3.org/50180
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php
typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
typo3/sysext/install/Classes/Controller/Action/Tool/ImportantActions.php

index 1fac4bf..9de3cfd 100644 (file)
@@ -435,7 +435,16 @@ class SchemaMigrator
 
             // We need to keep multiple table definitions at this point so
             // that Extensions can modify existing tables.
-            $tables[] = $createTableParser->parse();
+            try {
+                $tables[] = $createTableParser->parse();
+            } catch (\TYPO3\CMS\Core\Database\Schema\Exception\StatementException $statementException) {
+                // Enrich the error message with the full invalid statement
+                throw new \TYPO3\CMS\Core\Database\Schema\Exception\StatementException(
+                    $statementException->getMessage() . ' in statement ' . $statement,
+                    1476171315,
+                    $statementException
+                );
+            }
         }
 
         // Flatten the array of arrays by one level
index 5beccb2..6828c5b 100644 (file)
@@ -383,7 +383,14 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface
             $extTablesSqlContent .= file_get_contents($extTablesSqlFile);
         }
         if ($extTablesSqlContent !== '') {
-            $this->updateDbWithExtTablesSql($extTablesSqlContent);
+            try {
+                $this->updateDbWithExtTablesSql($extTablesSqlContent);
+            } catch (\TYPO3\CMS\Core\Database\Schema\Exception\StatementException $e) {
+                throw new ExtensionManagerException(
+                    $e->getMessage(),
+                    1476340371
+                );
+            }
         }
 
         $this->importStaticSqlFile($extension['siteRelPath']);
index c41dc7a..9c3c3e0 100644 (file)
@@ -88,7 +88,14 @@ class ImportantActions extends Action\AbstractAction
             $actionMessages = array_merge($actionMessages, $this->databaseAnalyzerExecute());
         }
         if (isset($this->postValues['set']['databaseAnalyzerAnalyze'])) {
-            $actionMessages[] = $this->databaseAnalyzerAnalyze();
+            try {
+                $actionMessages[] = $this->databaseAnalyzerAnalyze();
+            } catch (\TYPO3\CMS\Core\Database\Schema\Exception\StatementException $e) {
+                $message = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\ErrorStatus::class);
+                $message->setTitle('Database analysis failed');
+                $message->setMessage($e->getMessage());
+                $actionMessages[] = $message;
+            }
         }
 
         $this->view->assign('actionMessages', $actionMessages);