silverstripe/sapphire — pull request #1125 by tractorcow (2013-01-23 20:12:46+00:00)
Title: BUG Fix missing error email stacktrace

Error notification emails were previously only displaying stacktraces for some errors. After some investigation I determined that errors handled by errorHandler() were behaving as expected, but those handled by exceptionHandler() would not be able to generate a stacktrace.

exceptionHandler, it seems, passed in the stacktrace via the $context parameter, which for some reason is completely ignored inside the LogErrorEmailFormatter class, which instead used SS_Backtrace::backtrace to get the trace via debug_backtrace().

The problem with this mechanism is that the filtering functions did not have the intelligence to extract the exception's own stacktrace, and mistakenly filters out the entire trace leaving it blank.

In order to fix this issue I've instructed LogErrorEmailFormatter to use the $context parameter only for the stacktrace, and to keep things consistent, errorHandler now passes in debug_backtrace() for this parameter (where previously it was passing in null).

As a consequence the stacktrace provided is completely free of calls to debugging and error handling functions, meaning that SS_Backtrace no longer needs to filter those out.

Tested on Windows 7 x64.