[BUGFIX] Check if a valid logger is available in error handlers 98/56598/2
authorMarkus Klein <markus.klein@typo3.org>
Fri, 6 Apr 2018 19:39:45 +0000 (21:39 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 11 Apr 2018 13:42:01 +0000 (15:42 +0200)
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>
typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php
typo3/sysext/core/Classes/Error/ErrorHandler.php

index 2b7549a..e1669c5 100644 (file)
@@ -75,10 +75,12 @@ abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, Si
         // 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) {
index 12baf2a..1a179f2 100644 (file)
@@ -129,7 +129,9 @@ class ErrorHandler implements ErrorHandlerInterface, LoggerAwareInterface
         $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();