From c7ab5846df7e3f460b1c38e04a0946a914a35c19 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 16 Nov 2017 11:03:01 +1300 Subject: [PATCH] ENHANCEMENT Don't infer trace if explicitly provided Requires https://github.com/Seldaek/monolog/pull/1080 --- src/Logging/DetailedErrorFormatter.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Logging/DetailedErrorFormatter.php b/src/Logging/DetailedErrorFormatter.php index c55cc8bf1..2d47bd999 100644 --- a/src/Logging/DetailedErrorFormatter.php +++ b/src/Logging/DetailedErrorFormatter.php @@ -31,16 +31,18 @@ class DetailedErrorFormatter implements FormatterInterface } } - $trace = debug_backtrace(); + if (!isset($context['trace'])) { + $trace = debug_backtrace(); - // Filter out monolog plumbing from the trace - // If the context file & line isn't found in the trace, then the trace is most likely - // call to the fatal error handler and is not useful, so exclude it entirely - $i = $this->findInTrace($trace, $context['file'], $context['line']); - if ($i !== null) { - $context['trace'] = array_slice($trace, $i); - } else { - $context['trace'] = null; + // Filter out monolog plumbing from the trace + // If the context file & line isn't found in the trace, then the trace is most likely + // call to the fatal error handler and is not useful, so exclude it entirely + $i = $this->findInTrace($trace, $context['file'], $context['line']); + if ($i !== null) { + $context['trace'] = array_slice($trace, $i); + } else { + $context['trace'] = null; + } } }