[BUGFIX] Ensure to properly catch any connection exception 21/60421/2
authorBenni Mack <benni@typo3.org>
Tue, 9 Apr 2019 02:23:44 +0000 (04:23 +0200)
committerTobi Kretschmann <tobi@tobishome.de>
Wed, 10 Apr 2019 07:05:26 +0000 (09:05 +0200)
When e.g. a corrupt Database Connection is available
(MySQL down) and no connection is established, the Runtime
Exception should be caught as well.

In addition, the $message is more generic to avoid
any additional output for the end-users.

Resolves: #87993
Releases: master, 9.5
Change-Id: I2495426930d3fab841ff1632d778a945e73b521d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60421
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
typo3/sysext/frontend/Classes/Middleware/TypoScriptFrontendInitialization.php

index 7ccf12b..5085010 100644 (file)
@@ -66,9 +66,8 @@ class TypoScriptFrontendInitialization implements MiddlewareInterface, LoggerAwa
         try {
             $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
             $connection->connect();
-        } catch (ConnectionException $exception) {
-            // Cannot connect to current database
-            $message = 'Cannot connect to the configured database "' . $connection->getDatabase() . '"';
+        } catch (ConnectionException | \RuntimeException $exception) {
+            $message = 'Cannot connect to the configured database';
             $this->logger->emergency($message, ['exception' => $exception]);
             try {
                 return GeneralUtility::makeInstance(ErrorController::class)->unavailableAction($request, $message);