summaryrefslogtreecommitdiffstats
path: root/system/core/Common.php
diff options
context:
space:
mode:
authorJesse van Assen <jesse.v.assen@gmail.com>2013-07-06 10:42:14 +0200
committerJesse van Assen <jesse.v.assen@gmail.com>2013-07-06 10:42:14 +0200
commit7eb116a33937ec32bb30208561a27b8f0c26f496 (patch)
tree4a48c51dcf4292e2f793c216124dd2ba667b89fe /system/core/Common.php
parentae096ad4c074280cbb878216ffcada080055cea7 (diff)
The script is halted and a '500 Internal Server Error' is issued when a fatal error occurs.
Signed-off-by: Jesse van Assen <jesse.v.assen@gmail.com>
Diffstat (limited to 'system/core/Common.php')
-rw-r--r--system/core/Common.php21
1 files changed, 21 insertions, 0 deletions
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();
+ }
}
}