Register fatal error handler

This commit is contained in:
Garvin Hicking 2017-04-08 15:45:21 +02:00
parent 3e442e73ff
commit 86a17f9a2b
2 changed files with 23 additions and 1 deletions

View File

@ -186,7 +186,11 @@ if (!function_exists('errorToExceptionHandler')) {
* (string) 'debug' Developer build, specifically enabled.
*/
$debug_note = '<br />For more details set $serendipity[\'production\'] = \'debug\' in serendipity_config_local.inc.php to receive a stack-trace.';
if ($serendipity['production'] !== 'debug') {
$debug_note = '<br />For more details set $serendipity[\'production\'] = \'debug\' in serendipity_config_local.inc.php to receive a stack-trace.';
} else {
$debug_note = '';
}
// Debug environments shall be verbose...
if ($serendipity['production'] === 'debug') {
@ -235,6 +239,23 @@ document.body.insertBefore(fragment, document.body.childNodes[0]);
}
}
if (!function_exists('fatalErrorShutdownHandler')) {
/**
* Make fatal Errors readable
*
* @access public
*
* @return string constant error string as Exception
*/
function fatalErrorShutdownHandler() {
$last_error = error_get_last();
if ($last_error['type'] === E_ERROR) {
// fatal error send to
errorToExceptionHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
}
}
}
if (!function_exists('file_get_contents')) {
function file_get_contents($filename, $use_include_path = 0) {
$file = fopen($filename, 'rb', $use_include_path);

View File

@ -292,6 +292,7 @@ for ($i = 0; $i < 15; $i++ ) {
if (is_callable($serendipity['errorhandler'], false, $callable_name)) {
// set serendipity global error to exception handler
set_error_handler($serendipity['errorhandler'], $errLevel); // See error_reporting() earlier to see which errors are passed to the handler, deending on $serendipity['production'].
register_shutdown_function('fatalErrorShutdownHandler');
}
define('IS_up2date', version_compare($serendipity['version'], $serendipity['versionInstalled'], '<='));