Project

General

Profile

Actions

Bug #87993

closed

Uncaught TYPO3 Exception: Call to a member function getDatabase() on null

Added by Robert Vock about 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2019-03-25
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I've got some random exceptions in my TYPO3 log:

Sun, 24 Mar 2019 04:01:57 +0100 [CRITICAL] request="" component="TYPO3.CMS.Core.Error.ProductionExceptionHandler": Core: Exception handler (WEB): Uncaught TYPO3 Exception: Call to a member function getDatabase() on null | Error thrown in file PATH/public/typo3/sysext/frontend/Classes/Middleware/TypoScriptFrontendInitialization.php in line 74. Requested URL: https://www.example.de/ - {" 
TYPO3_MODE":"FE","exception":{}}

It appears they are generated in TypoScriptFrontendInitialization :

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);
    }
}

The catch block tries to use the variable $connection, even though it might not be initialized if an exception occurred.

I believe the exception leading to the catch-block might be generated because some cronjobs are running and mysql is busy.

Actions

Also available in: Atom PDF