dopetalk

Technology => SMF Forum Code Modifications => Topic started by: Chip on February 09, 2018, 07:31:46 AM

Title: Stack Trace
Post by: Chip on February 09, 2018, 07:31:46 AM
http://custom.simplemachines.org/mods/index.php?mod=3953

When errors are tracked when this mod is installed, a stack trace will be captured with them to be able to identify the code path involved.

> not working unfortunately - DEV/TEST debugging only
Title: Re: Stack Trace
Post by: Chip on July 25, 2018, 07:21:34 PM
is working now - Admin > Configuration > Server Settings > Disable evaluation of templates ticked

an enhancement: a deeper stack trace and (bug fix) prevention of spurious error "symptoms" finding their way to the screen @dougiefresh:

In Sources/Errors.php,

find:
Code: [Select]
foreach (debug_backtrace() as $this_error)
{
// We don't need to log the error handler itself.
if (substr($this_error['file'], -10) == 'Errors.php' && $this_error['function'] == 'log_error')
continue;
if (substr($this_error['file'], -8) == 'Subs.php' && $this_error['function'] == 'error_handler')
continue;

// Certain anonymous calls do not end up in this fashion.
$frame = array(
'line' => $smcFunc['htmlspecialchars'](strtr($this_error['file'], $repl) . ':' . $this_error['line']),
'function' => $smcFunc['htmlspecialchars']((!empty($this_error['class']) ? $this_error['class'] . '->' : '') . $this_error['function']),
);
if ($frame['line'] != ':')
$stack[] = $frame;
}

change to:
Code: [Select]
foreach (debug_backtrace() as $this_error)
{
// We don't need to log the error handler itself.
if (isset($this_error['file']) && substr($this_error['file'], -10) == 'Errors.php' && $this_error['function'] == 'log_error')
continue;
if (isset($this_error['file']) && substr($this_error['file'], -8) == 'Subs.php' && $this_error['function'] == 'error_handler')
continue;

// Certain anonymous calls do not end up in this fashion.
$frame = array(
'line' => isset($this_error['file']) ? $smcFunc['htmlspecialchars'](strtr($this_error['file'], $repl) . ':' . $this_error['line']) : '',
'function' => $smcFunc['htmlspecialchars']((!empty($this_error['class']) ? $this_error['class'] . '->' : '') . $this_error['function']),
);
if ($frame['line'] != ':')
$stack[] = $frame;
}
SimplePortal 2.3.6 © 2008-2014, SimplePortal