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(+) (limited to 'system/core/Common.php') 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 d6f3d315e543a6c81917c1c2719748e018e43a5f Mon Sep 17 00:00:00 2001 From: vkeranov Date: Sat, 14 Sep 2013 21:39:49 +0300 Subject: No need of this anymore --- system/core/Common.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index 286deccda..e24f8854d 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -429,7 +429,6 @@ if ( ! function_exists('log_message')) * * @param string the error level: 'error', 'debug' or 'info' * @param string the error message - * @param bool whether the error is a native PHP error * @return void */ function log_message($level, $message) @@ -588,7 +587,7 @@ if ( ! function_exists('_shutdown_handler')) * 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 + * 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 @@ -753,4 +752,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ \ No newline at end of file +/* Location: ./system/core/Common.php */ -- cgit v1.2.3-24-g4f1b From 13c818ee2f7424050cf363dceac7512bf9f9f943 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 14 Sep 2013 21:44:36 +0300 Subject: [ci skip] Remove empty lines --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index e24f8854d..c25707e50 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -752,4 +752,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file -- 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(-) (limited to 'system/core/Common.php') 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 f964b16f3db95d655420dfae2012ee9fbb98a1a8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Nov 2013 17:04:55 +0200 Subject: Deprecate CI_Input::is_cli_request() and add common function is_cli() to replace it Calls to this function are often needed before the Input library is available --- system/core/Common.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index 56008efe8..c008bd571 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -355,6 +355,24 @@ if ( ! function_exists('is_https')) // ------------------------------------------------------------------------ +if ( ! function_exists('is_cli')) +{ + + /** + * Is CLI? + * + * Test to see if a request was made from the command line. + * + * @return bool + */ + function is_cli() + { + return (PHP_SAPI === 'cli' OR defined('STDIN')); + } +} + +// ------------------------------------------------------------------------ + if ( ! function_exists('show_error')) { /** -- cgit v1.2.3-24-g4f1b From afca352b30466ecff38dc3106321851a030af623 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Nov 2013 15:26:59 +0200 Subject: Remove a function_exists() check for error_get_last() It was only relevant until we dropped support for PHP < 5.2 --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index c008bd571..00e303098 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -634,7 +634,7 @@ if ( ! function_exists('_shutdown_handler')) */ function _shutdown_handler() { - $last_error = function_exists('error_get_last') ? error_get_last() : NULL; + $last_error = error_get_last(); if (isset($last_error) && ($last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))) { -- cgit v1.2.3-24-g4f1b From 2b284f9b171ba0e0886db15772a6a62e9155f74f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 25 Jan 2014 00:25:56 +0200 Subject: [ci skip] Add a link to PHP bug 54709 in is_really_writable()'s docblock --- system/core/Common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index 00e303098..cfc63c2aa 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -76,6 +76,7 @@ if ( ! function_exists('is_really_writable')) * the file, based on the read-only attribute. is_writable() is also unreliable * on Unix servers if safe_mode is on. * + * @link https://bugs.php.net/bug.php?id=54709 * @param string * @return void */ -- cgit v1.2.3-24-g4f1b From 76160bc9ea5f0f4c653300231e34faa445342d83 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 30 Jan 2014 22:26:14 +0200 Subject: Previous 2 commits were just dumb --- system/core/Common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index cfc63c2aa..e5dd84369 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -598,14 +598,14 @@ if ( ! function_exists('_exception_handler')) return; } + $_error->log_exception($severity, $message, $filepath, $line); + // Should we display the error? if ((bool) ini_get('display_errors') === TRUE) { $_error->show_php_error($severity, $message, $filepath, $line); } - $_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 -- cgit v1.2.3-24-g4f1b From aaa8ddb5a48af8f37cf1015a7768957cce41acd3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 3 Feb 2014 14:10:44 +0200 Subject: [ci skip] Update info on function_usable --- system/core/Common.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index e5dd84369..07f0c6dfd 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -756,6 +756,11 @@ if ( ! function_exists('function_usable')) * *suhosin.executor.disable_eval*. These settings will just * terminate script execution if a disabled function is executed. * + * The above described behavior turned out to be a bug in Suhosin, + * but even though a fix was commited for 0.9.34 on 2012-02-12, + * that version is yet to be released. This function will therefore + * be just temporary, but would probably be kept for a few years. + * * @link http://www.hardened-php.net/suhosin/ * @param string $function_name Function to check for * @return bool TRUE if the function exists and is safe to call, -- cgit v1.2.3-24-g4f1b From 871754af60251993d640981e107d2def5f2db396 Mon Sep 17 00:00:00 2001 From: darwinel Date: Tue, 11 Feb 2014 17:34:57 +0100 Subject: 2013 > 2014 Update copyright notices from 2013 to 2014. And update one calendar example in user_guide from year 2013/2014 to 2014/2015. --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index 07f0c6dfd..16a916a01 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b