Bug #84646

Exception in ErrorHandler if problem instantiating logger (Reboustness)

Added by Sybille Peters over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Logging
Target version:
-
Start date:
2018-04-06
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In the BE the following error is displayed if the logging api is enabled:

 Fatal error: Uncaught Error: Call to a member function log() on null in /var/www/t3coredev/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 132
( ! ) Error: Call to a member function log() on null in /var/www/t3coredev/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 132

I am using a current master (TYPO3 9.2-dev).

I use a similar snippet in several TYPO3 8 instances:

typo3conf/AdditionalConfiguration.php:

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
    // configuration for ERROR level log entries
  \TYPO3\CMS\Core\Log\LogLevel::ERROR => [
      // add a FileWriter
    'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => [
       // configuration for the writer
      'logFile' => 'typo3temp/logs/typo3-error.log'
    ]
  ],

  \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
      // add a FileWriter
    'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => [
       // configuration for the writer
      'logFile' => 'typo3temp/logs/typo3-debug.log'
    ]
  ]    

];

ErrorHandler uses the new loggerAwareTrait functionality, so that should be fine.

stacktrace.png View (170 KB) Sybille Peters, 2018-04-06 17:19


Related issues

Related to TYPO3 Core - Bug #84654: If problem with creation of logger, an Exception is thrown: A cache with identifier "assets" does not exist New 2018-04-07

Associated revisions

Revision 125e3463 (diff)
Added by Markus Klein over 1 year ago

[BUGFIX] Check if a valid logger is available in error handlers

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 <>
Reviewed-by: Mathias Schreiber <>
Tested-by: Mathias Schreiber <>
Reviewed-by: Sybille Peters <>
Tested-by: Sybille Peters <>
Reviewed-by: Stefan Neufeind <>
Tested-by: Stefan Neufeind <>

History

#1 Updated by Markus Klein over 1 year ago

1) typo3temp/logs/typo3-error.log should actually be typo3temp/var/logs/typo3-error.log since v8
2) The logging API is always enabled independent of any configuration you add yourself
3) Does it work if you remove your configuration?
4) Do you have a stacktrace showing why the ErrorHandler is called firstplace?

#2 Updated by Sybille Peters over 1 year ago

I narrowed it down: It was a permission problem for my path `typo3temp/logs`. I had manually created that, webserver did not have write permission. Will use the path you pointed out in the future.

Still sending the stacktrace for reference.

Stack trace:

PHP Fatal error:  Uncaught Error: Call to a member function log() on null 
in /var/www/t3coredev/typo3/sysext/core/Classes/Error/ErrorHandler.php:132
Stack trace:
#0 [internal function]: TYPO3\\CMS\\Core\\Error\\ErrorHandler->handleError(2, 'fopen(/var/www/...', '/var/www/t3core...', 1925, Array)
#1 /var/www/t3coredev/typo3/sysext/core/Classes/Utility/GeneralUtility.php(1925): 
fopen('/var/www/t3core...', 'wb')
#2 /var/www/t3coredev/typo3/sysext/core/Classes/Log/Writer/FileWriter.php(197):
TYPO3\\CMS\\Core\\Utility\\GeneralUtility::writeFile('/var/www/t3core...', '')
#3 /var/www/t3coredev/typo3/sysext/core/Classes/Log/Writer/FileWriter.php(160): 
TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter->createLogFile()
#4 /var/www/t3coredev/typo3/sysext/core/Classes/Log/Writer/FileWriter.php(95): 
TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter->openLogFile()
#5 /var/www/t3coredev/typo3/sysext/core/Classes/Log/Writer/AbstractWriter.php(35): 
TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter->setLogFile('typo3temp/logs/...')
#6 /var/www/t3coredev/typo3/sysext/core/Classes/Log/Writer/ in /var/www/t3coredev
/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 132

#3 Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56598

#4 Updated by Sybille Peters over 1 year ago

  • Description updated (diff)

#5 Updated by Sybille Peters over 1 year ago

  • Related to Bug #84654: If problem with creation of logger, an Exception is thrown: A cache with identifier "assets" does not exist added

#6 Updated by Sybille Peters over 1 year ago

  • Subject changed from Exception in ErrorHandler as soon as logging API is enabled. to Exception in ErrorHandler if problem instantiating logger (Reboustness)

#7 Updated by Markus Klein over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#8 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF