diff options
| author | Greg Roach <fisharebest@gmail.com> | 2014-04-27 09:21:36 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2014-04-27 09:21:36 +0100 |
| commit | a24329d817c8980a540b020fbbd1be52e1766d32 (patch) | |
| tree | 7f81f397e56c73a7f27f353e7cf7021496ba938a | |
| parent | 577ee5e259b6dc6e3332e6f279ad8fca380b297b (diff) | |
| download | webtrees-a24329d817c8980a540b020fbbd1be52e1766d32.tar.gz webtrees-a24329d817c8980a540b020fbbd1be52e1766d32.tar.bz2 webtrees-a24329d817c8980a540b020fbbd1be52e1766d32.zip | |
Missing change in previous commit
| -rwxr-xr-x | includes/session.php | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/includes/session.php b/includes/session.php index 4559e8d3b1..4456237bec 100755 --- a/includes/session.php +++ b/includes/session.php @@ -203,7 +203,51 @@ require WT_ROOT.'includes/functions/functions_date.php'; require WT_ROOT.'includes/functions/functions_charts.php'; require WT_ROOT.'includes/functions/functions_utf-8.php'; -set_error_handler('wt_error_handler'); +// Set a custom error handler +set_error_handler(function ($errno, $errstr, $errfile, $errline) { + if ((error_reporting() > 0)&&($errno<2048)) { + if (WT_ERROR_LEVEL==0) { + return; + } + $fmt_msg="<br>ERROR {$errno}: {$errstr}<br>"; + $log_msg="ERROR {$errno}: {$errstr};"; + // Although debug_backtrace should always exist in PHP5, without this check, PHP sometimes crashes. + // Possibly calling it generates an error, which causes infinite recursion?? + if ($errno < 16 && function_exists("debug_backtrace") && strstr($errstr, "headers already sent by") === false) { + $backtrace = debug_backtrace(); + $num = count($backtrace); + if (WT_ERROR_LEVEL == 1) { + $num = 1; + } + for ($i = 0; $i < $num; $i++) { + if ($i === 0) { + $fmt_msg .= "0 Error occurred on "; + $log_msg .= "\n0 Error occurred on "; + } else { + $fmt_msg .= "{$i} called from "; + $log_msg .= "\n{$i} called from "; + } + if (isset($backtrace[$i]["line"]) && isset($backtrace[$i]["file"])) { + $fmt_msg .= "line <b>{$backtrace[$i]['line']}</b> of file <b>".basename($backtrace[$i]['file'])."</b>"; + $log_msg .= "line {$backtrace[$i]['line']} of file ".basename($backtrace[$i]['file']); + } + if ($i<$num-1) { + $fmt_msg .= " in function <b>".$backtrace[$i+1]['function']."</b>"; + $log_msg .= " in function ".$backtrace[$i+1]['function']; + } + $fmt_msg .= "<br>"; + } + } + echo $fmt_msg; + if (function_exists('AddToLog')) { + AddToLog($log_msg, 'error'); + } + if ($errno == 1) { + die(); + } + } + return false; +}); // Load our configuration file, so we can connect to the database if (file_exists(WT_ROOT.'data/config.ini.php')) { |
