diff --git a/libraries/src/Exception/ExceptionHandler.php b/libraries/src/Exception/ExceptionHandler.php index 7ad3c6375410f..ab96f5e7287ca 100644 --- a/libraries/src/Exception/ExceptionHandler.php +++ b/libraries/src/Exception/ExceptionHandler.php @@ -94,8 +94,14 @@ public static function render($error) // Push the error object into the document $document->setError($error); - // Clear buffered output at all levels in non-test mode - $callerFunction = static::getCallerFunctionName(); + // Clear buffered output at all levels + while (ob_get_level()) + { + ob_end_clean(); + } + + // This is needed to ensure the test suite can still get the output buffer + ob_start(); $document->setTitle(Text::_('ERROR') . ': ' . $error->getCode()); @@ -176,7 +182,7 @@ public static function render($error) protected static function getCallerFunctionName() { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - + return isset($backtrace[2]['function']) ? $backtrace[2]['function'] : false; }