Skip to content
Snippets Groups Projects
Commit 360d896d authored by Benni Mack's avatar Benni Mack Committed by Andreas Fernandez
Browse files

[TASK] Remove DB Connection check in Frontend Requests

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: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarStefan Froemken <froemken@gmail.com>
Tested-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarStefan Froemken <froemken@gmail.com>
Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 4736a751
Branches
Tags
No related merge requests found
......@@ -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);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment