summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-03-04 13:59:53 +0100
committerAndrey Andreev <narf@bofh.bg>2013-03-04 13:59:53 +0100
commitbb5cf0a51ce1aecf1dc5ebeb38336f59388321ef (patch)
tree81696844dd60466d1f1a1c0a4d8bbeb82f9a8b1c /system/core
parentfa01ae4b3a2ed51a93590527c04295eb8cba4e40 (diff)
parent8626e93d5b4362c86a58933dda9206ac8810476d (diff)
Merge pull request #2190 from danhunsaker/feature/exit-status
Updated all CLI-valid cases of exit() to return a valid code
Diffstat (limited to 'system/core')
-rw-r--r--system/core/Common.php29
-rw-r--r--system/core/Exceptions.php2
-rw-r--r--system/core/Input.php3
3 files changed, 27 insertions, 7 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index ee9bb2e87..9baf5e315 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -1,3 +1,4 @@
+
<?php
/**
* CodeIgniter
@@ -175,7 +176,8 @@ if ( ! function_exists('load_class'))
// Note: We use exit() rather then show_error() in order to avoid a
// self-referencing loop with the Exceptions class
set_status_header(503);
- exit('Unable to locate the specified class: '.$class.'.php');
+ echo 'Unable to locate the specified class: '.$class.'.php';
+ exit(EXIT_UNKNOWN_CLASS);
}
// Keep track of what we just loaded
@@ -248,14 +250,16 @@ if ( ! function_exists('get_config'))
elseif ( ! $found)
{
set_status_header(503);
- exit('The configuration file does not exist.');
+ echo 'The configuration file does not exist.';
+ exit(EXIT_CONFIG);
}
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
{
set_status_header(503);
- exit('Your config file does not appear to be formatted correctly.');
+ echo 'Your config file does not appear to be formatted correctly.';
+ exit(EXIT_CONFIG);
}
// Are any values being dynamically replaced?
@@ -367,9 +371,24 @@ if ( ! function_exists('show_error'))
*/
function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
{
+ $status_code = abs($status_code);
+ if ($status_code < 100)
+ {
+ $exit_status = $status_code + EXIT__AUTO_MIN;
+ if ($exit_status > EXIT__AUTO_MAX)
+ {
+ $exit_status = EXIT_ERROR;
+ }
+ $status_code = 500;
+ }
+ else
+ {
+ $exit_status = EXIT_ERROR;
+ }
+
$_error =& load_class('Exceptions', 'core');
echo $_error->show_error($heading, $message, 'error_general', $status_code);
- exit;
+ exit($exit_status);
}
}
@@ -392,7 +411,7 @@ if ( ! function_exists('show_404'))
{
$_error =& load_class('Exceptions', 'core');
$_error->show_404($page, $log_error);
- exit;
+ exit(EXIT_UNKNOWN_FILE);
}
}
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index e6023e73b..9c68d06a5 100644
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -117,7 +117,7 @@ class CI_Exceptions {
}
echo $this->show_error($heading, $message, 'error_404', 404);
- exit;
+ exit(EXIT_UNKNOWN_FILE);
}
// --------------------------------------------------------------------
diff --git a/system/core/Input.php b/system/core/Input.php
index 68a8fe03f..8d491e055 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -745,7 +745,8 @@ class CI_Input {
if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str))
{
set_status_header(503);
- exit('Disallowed Key Characters.');
+ echo 'Disallowed Key Characters.';
+ exit(EXIT_USER_INPUT);
}
// Clean UTF-8 if supported