Skip to content

Commit

Permalink
[BUGFIX] Check if a valid logger is available in error handlers
Browse files Browse the repository at this point in the history
If the logger for some reason couldn't be created by GeneralUtility
or causes an exception or error itself the triggered ErrorHandler or
ExceptionHandler must not try to use the (non-existing) logger.

Resolves: #84646
Releases: master, 8.7
Change-Id: I46ba22bf4141c37db6530912b9e34252d1fb462c
Reviewed-on: https://review.typo3.org/56598
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Sybille Peters <sypets@gmx.de>
Tested-by: Sybille Peters <sypets@gmx.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
  • Loading branch information
liayn authored and neufeind committed Apr 11, 2018
1 parent ebe340c commit 125e346
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php
Expand Up @@ -75,10 +75,12 @@ protected function writeLogEntries(\Throwable $exception, $context)
// caused by this. Therefor we cannot do any database operation,
// otherwise this will lead into recurring exceptions.
try {
$this->logger->critical($logTitle . ': ' . $logMessage, [
'TYPO3_MODE' => TYPO3_MODE,
'exception' => $exception
]);
if ($this->logger) {
$this->logger->critical($logTitle . ': ' . $logMessage, [
'TYPO3_MODE' => TYPO3_MODE,
'exception' => $exception
]);
}
// Write error message to sys_log table
$this->writeLog($logTitle . ': ' . $logMessage);
} catch (\Exception $exception) {
Expand Down
4 changes: 3 additions & 1 deletion typo3/sysext/core/Classes/Error/ErrorHandler.php
Expand Up @@ -129,7 +129,9 @@ public function handleError($errorLevel, $errorMessage, $errorFile, $errorLine)
$logTitle = 'Core: Error handler (' . TYPO3_MODE . ')';
$message = $logTitle . ': ' . $message;

$this->logger->log(LogLevel::NOTICE - $severity, $message);
if ($this->logger) {
$this->logger->log(LogLevel::NOTICE - $severity, $message);
}

// Write error message to TSlog (admin panel)
$timeTracker = $this->getTimeTracker();
Expand Down

0 comments on commit 125e346

Please sign in to comment.