From 7eb116a33937ec32bb30208561a27b8f0c26f496 Mon Sep 17 00:00:00 2001 From: Jesse van Assen Date: Sat, 6 Jul 2013 10:42:14 +0200 Subject: The script is halted and a '500 Internal Server Error' is issued when a fatal error occurs. Signed-off-by: Jesse van Assen --- system/core/Common.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/system/core/Common.php b/system/core/Common.php index 93cd0a0ae..7553f4ae6 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -577,6 +577,19 @@ if ( ! function_exists('_exception_handler')) */ function _exception_handler($severity, $message, $filepath, $line) { + $is_error = ((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity; + + // When an error occurred, set the status header to '500 Internal Server Error' + // to indicate to the client something went wrong. + // This can't be done within the $_error->show_php_error method because + // it is only called when the display_errors flag is set (which isn't usually + // the case in a production environment) or when errors are ignored because + // they are above the error_reporting threshold. + if ($is_error) + { + set_status_header(500); + } + $_error =& load_class('Exceptions', 'core'); // Should we ignore the error? We'll get the current error_reporting @@ -593,6 +606,14 @@ if ( ! function_exists('_exception_handler')) } $_error->log_exception($severity, $message, $filepath, $line); + + // If the error is fatal, the execution of the script should be stopped because + // errors can't be recovered from. Halting the script conforms with PHP's + // default error handling. See http://www.php.net/manual/en/errorfunc.constants.php + if ($is_error) + { + exit(); + } } } -- cgit v1.2.3-24-g4f1b From cf60fa7ac654a15e00888eef469838ef4bf47204 Mon Sep 17 00:00:00 2001 From: Jesse van Assen Date: Fri, 27 Sep 2013 11:58:44 +0200 Subject: Script is killed with the proper exit code. --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Common.php b/system/core/Common.php index 7553f4ae6..d88b0867b 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -612,7 +612,7 @@ if ( ! function_exists('_exception_handler')) // default error handling. See http://www.php.net/manual/en/errorfunc.constants.php if ($is_error) { - exit(); + exit(EXIT_ERROR); } } } -- cgit v1.2.3-24-g4f1b From 871d8f67611d94e2662dd0ac6e06b96accc954e6 Mon Sep 17 00:00:00 2001 From: Jesse van Assen Date: Fri, 27 Sep 2013 12:04:37 +0200 Subject: Added changelog entry. --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2adbca19d..f5e2da738 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -501,6 +501,7 @@ Bug fixes for 3.0 - Fixed a bug (#2380) - :doc:`URI Routing ` method ``fetch_method()`` returned 'index' if the requested method name matches its controller name. - Fixed a bug (#2388) - :doc:`Email Library ` used to ignore attachment errors, resulting in broken emails being sent. - Fixed a bug (#2498) - :doc:`Form Validation Library ` rule **valid_base64** only checked characters instead of actual validity. +- Fixed a bug (#2515) - The script now halts when a fatal error occurs, instead of continuing. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b