[TASK] Remove DB Connection check in Frontend Requests 66/60866/3
authorBenni Mack <benni@typo3.org>
Mon, 3 Jun 2019 14:56:07 +0000 (16:56 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 5 Jun 2019 04:22:34 +0000 (06:22 +0200)
The check if the pages table is accessible is removed.

In TYPO3 v9 this was right after the TSFE creation due to 100%
backwards-compatibility in terms of previous code which has now
vanished (a legacy hook).

This change removes the database initialization check as it is done
already anyway earlier in Bootstrap.

Resolves: #88481
Releases: master
Change-Id: I7ca0c068ece433e9c545163121373b0de2af086d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60866
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/frontend/Classes/Middleware/TypoScriptFrontendInitialization.php

index 5085010..55fba5f 100644 (file)
@@ -15,17 +15,11 @@ namespace TYPO3\CMS\Frontend\Middleware;
  * The TYPO3 project - inspiring people to share!
  */
 
-use Doctrine\DBAL\Exception\ConnectionException;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Server\MiddlewareInterface;
 use Psr\Http\Server\RequestHandlerInterface;
-use Psr\Log\LoggerAwareInterface;
-use Psr\Log\LoggerAwareTrait;
-use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Controller\ErrorController;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
 /**
@@ -34,13 +28,10 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
  *
  * @internal this middleware might get removed in TYPO3 v10.0.
  */
-class TypoScriptFrontendInitialization implements MiddlewareInterface, LoggerAwareInterface
+class TypoScriptFrontendInitialization implements MiddlewareInterface
 {
-    use LoggerAwareTrait;
-
     /**
-     * Creates an instance of TSFE and sets it as a global variable,
-     * also pings the database in order ensure a valid database connection.
+     * Creates an instance of TSFE and sets it as a global variable.
      *
      * @param ServerRequestInterface $request
      * @param RequestHandlerInterface $handler
@@ -61,20 +52,6 @@ class TypoScriptFrontendInitialization implements MiddlewareInterface, LoggerAwa
         if ($request->getParsedBody()['no_cache'] ?? $request->getQueryParams()['no_cache'] ?? false) {
             $GLOBALS['TSFE']->set_no_cache('&no_cache=1 has been supplied, so caching is disabled! URL: "' . (string)$request->getUri() . '"');
         }
-
-        // Set up the database connection and see if the connection can be established
-        try {
-            $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
-            $connection->connect();
-        } 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);
-            } catch (ServiceUnavailableException $e) {
-                throw new ServiceUnavailableException($message, 1526013723);
-            }
-        }
         return $handler->handle($request);
     }
 }