summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2013-10-21 13:26:18 +0200
committerAndrey Andreev <narf@devilix.net>2013-10-21 13:26:18 +0200
commit0850a2857ef24dfa8e5a80da7b4049f70a679d29 (patch)
treee4efd5dabed176f9595f67689014b92302e2ea3f
parent6c85442746c46009cdf3fe517465e174a91cc4c5 (diff)
parent871d8f67611d94e2662dd0ac6e06b96accc954e6 (diff)
Fix #2515 (manually merge PR #2516)
-rw-r--r--system/core/Common.php29
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 26 insertions, 4 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index c25707e50..56008efe8 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -549,14 +549,27 @@ if ( ! function_exists('_exception_handler'))
* to display errors based on the current error_reporting level.
* We do that with the use of a PHP error template.
*
- * @param int
- * @param string
- * @param string
- * @param int
+ * @param int $severity
+ * @param string $message
+ * @param string $filepath
+ * @param int $line
* @return void
*/
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
@@ -573,6 +586,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(EXIT_ERROR);
+ }
}
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 9f6feb744..8f5dfe540 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -620,6 +620,7 @@ Bug fixes for 3.0
- Fixed a bug (#33) - Script execution was terminated when an invalid cookie key was encountered.
- Fixed a bug (#2681) - ``CI_Security::entity_decode()`` used the `PREG_REPLACE_EVAL` flag, which is deprecated since PHP 5.5.
- Fixed a bug (#2691) - nested transactions could end in a deadlock when an error is encountered with *db_debug* set to TRUE.
+- Fixed a bug (#2515) - ``_exception_handler()`` used to send the 200 "OK" HTTP status code and didn't stop script exection even on fatal errors.
Version 2.1.4
=============