mirror of
https://github.com/friendica/friendica
synced 2025-02-10 21:34:02 +00:00
Log trigger_error() of deprecated code
This commit is contained in:
parent
02cde27a12
commit
af96a957cd
1 changed files with 16 additions and 4 deletions
|
@ -197,7 +197,7 @@ class ErrorHandler
|
|||
E_STRICT => LogLevel::NOTICE,
|
||||
E_RECOVERABLE_ERROR => LogLevel::ERROR,
|
||||
E_DEPRECATED => LogLevel::NOTICE,
|
||||
E_USER_DEPRECATED => LogLevel::NOTICE,
|
||||
E_USER_DEPRECATED => LogLevel::WARNING,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -248,17 +248,29 @@ class ErrorHandler
|
|||
*/
|
||||
public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool
|
||||
{
|
||||
if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
|
||||
if ($this->handleOnlyReportedErrors && !(error_reporting() & $code) && $code !== E_USER_DEPRECATED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
|
||||
array_shift($trace); // Exclude handleError from trace
|
||||
|
||||
if ($code === E_USER_DEPRECATED && $trace[0]['function'] ?? '' === 'trigger_error') {
|
||||
$calledPlace = $trace[1] ?? [];
|
||||
|
||||
$message .= sprintf(
|
||||
' It was called in `%s`%s.',
|
||||
$calledPlace['file'],
|
||||
isset($calledPlace['line']) ? ' in line ' . $calledPlace['line'] : ''
|
||||
);
|
||||
}
|
||||
|
||||
// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
|
||||
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
|
||||
$level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL;
|
||||
$this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
|
||||
} else {
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
array_shift($trace); // Exclude handleError from trace
|
||||
$this->lastFatalTrace = $trace;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue