From 86a17f9a2b3abb98421a947773391960677fba72 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Sat, 8 Apr 2017 15:45:21 +0200 Subject: [PATCH] Register fatal error handler --- include/compat.inc.php | 23 ++++++++++++++++++++++- serendipity_config.inc.php | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/compat.inc.php b/include/compat.inc.php index f67d0cb8..1c2cb868 100644 --- a/include/compat.inc.php +++ b/include/compat.inc.php @@ -186,7 +186,11 @@ if (!function_exists('errorToExceptionHandler')) { * (string) 'debug' Developer build, specifically enabled. */ - $debug_note = '
For more details set $serendipity[\'production\'] = \'debug\' in serendipity_config_local.inc.php to receive a stack-trace.'; + if ($serendipity['production'] !== 'debug') { + $debug_note = '
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); diff --git a/serendipity_config.inc.php b/serendipity_config.inc.php index 0cab62de..37d91bcf 100644 --- a/serendipity_config.inc.php +++ b/serendipity_config.inc.php @@ -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'], '<='));