getQueryParams() due to * hooks who could have $_GET/$_POST modified before. * * @internal */ class TypoScriptFrontendInitialization implements MiddlewareInterface, LoggerAwareInterface { 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. * * @param ServerRequestInterface $request * @param RequestHandlerInterface $handler * @return ResponseInterface */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $GLOBALS['TSFE'] = GeneralUtility::makeInstance( TypoScriptFrontendController::class, null, GeneralUtility::_GP('id'), GeneralUtility::_GP('type'), null, GeneralUtility::_GP('cHash'), null, GeneralUtility::_GP('MP') ); if (GeneralUtility::_GP('no_cache')) { $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 $exception) { // Cannot connect to current database $message = 'Cannot connect to the configured database "' . $connection->getDatabase() . '"'; $this->logger->emergency($message, ['exception' => $exception]); try { return GeneralUtility::makeInstance(ErrorController::class)->unavailableAction($request, $message); } catch (ServiceUnavailableException $e) { throw new ServiceUnavailableException($message, 1526013723); } } // Call post processing function for DB connection: $_params = ['pObj' => &$GLOBALS['TSFE']]; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] ?? [] as $_funcRef) { GeneralUtility::callUserFunction($_funcRef, $_params, $GLOBALS['TSFE']); } return $handler->handle($request); } }