Bug #88444
closedTYPO3 error handler ignores error_reporting level of php.ini
0%
Description
TYPO3 uses the PHP error handling function for deprecation messages since TYPO3 v9.0, but defining a error_reporting
level in php.ini
like
error_reporting = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_STRICT
in order to ignore deprecation messages on a production server has no effect.
The deprecations are logged by calling trigger_error($message, E_USER_DEPRECATED)
which leads to the php error handler being executed even if the currently configured error_reporting()
would ignore E_USER_DEPRECATED
messages.
The ErrorHandler only uses the value from [SYS][errorHandlerErrors]
which does not offer an option to use the server defined error_reporting
level of php.ini
:
https://github.com/TYPO3/TYPO3.CMS/blob/v9.5.7/typo3/sysext/core/Classes/Error/ErrorHandler.php#L66
/** * Registers this class as default error handler * * @param int $errorHandlerErrors The integer representing the E_* error level which should be */ public function __construct($errorHandlerErrors) { $excludedErrors = E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR; // reduces error types to those a custom error handler can process $this->errorHandlerErrors = $errorHandlerErrors & ~$excludedErrors; set_error_handler([$this, 'handleError'], $this->errorHandlerErrors); }
https://github.com/TYPO3/TYPO3.CMS/blob/v9.5.7/typo3/sysext/core/Classes/Core/Bootstrap.php#L669
$errorHandlerErrors = $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']; ... $errorHandler = GeneralUtility::makeInstance($errorHandlerClassName, $errorHandlerErrors);
Using the server defined error_reporting
level of php.ini
could be achieved by e.g. allowing a value like server_error_reporting
for ['SYS']['errorHandlerErrors']
which would lead to the value of error_reporting()
being used in
https://github.com/TYPO3/TYPO3.CMS/blob/v9.5.7/typo3/sysext/core/Classes/Core/Bootstrap.php#L701
$errorHandler = GeneralUtility::makeInstance($errorHandlerClassName, $errorHandlerErrors);