summaryrefslogtreecommitdiffstats
path: root/system/core/Common.php
diff options
context:
space:
mode:
authorKaiwang Chen <kaiwang.chen@gmail.com>2013-09-11 07:09:41 +0200
committerKaiwang Chen <kaiwang.chen@gmail.com>2013-09-11 07:09:41 +0200
commit21fe9daf1cdc86cbd8800515166e19b2f8879b71 (patch)
tree0bc9cad2bdb1a47c62df87b5716098a8d14b4a60 /system/core/Common.php
parent4013be3d0953612ce081802bb6cc331338d8f58a (diff)
Simulate a complete custom exception handler by redirecting uncaught events.
Diffstat (limited to 'system/core/Common.php')
-rw-r--r--system/core/Common.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index 7f296b133..0353a9d10 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -577,6 +577,35 @@ if ( ! function_exists('_exception_handler'))
}
}
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('_shutdown_handler'))
+{
+ /**
+ * Shutdown Handler
+ *
+ * This is the shutdown handler that is declared at the top
+ * of CodeIgniter.php. The main reason we use this is to simulate
+ * a complete custom exception handler.
+ *
+ * E_STRICT is purposivly neglected because such events may have
+ * been caught. Duplication or none? None is preferred for now.
+ *
+ * @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a
+ * @return void
+ */
+ function _shutdown_handler()
+ {
+ $last_error = function_exists('error_get_last') ? error_get_last() : NULL;
+ if (isset($last_error) &&
+ ($last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING)))
+ {
+ chdir(CIPATH);
+ _exception_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']);
+ }
+ }
+}
+
// --------------------------------------------------------------------
if ( ! function_exists('remove_invisible_characters'))