summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
authorDaniel Hunsaker <danhunsaker@gmail.com>2013-02-23 03:17:56 +0100
committerDaniel Hunsaker <danhunsaker@gmail.com>2013-02-23 03:18:51 +0100
commit3b5b7f48848d098c6190781f8790a1b0dcb0217c (patch)
treeaf75fafeb3c822b720ee3da9b23b9d7a9e6ba020 /system/core
parent44a6d1da2be916fe0f23a3ea4d5fcb391d7f65dd (diff)
Updated exit codes as constant values
Re-allocated exit status codes according to three references, which follow: BSD sysexits.h:http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits GNU recomendations:http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html Bash scripting:http://tldp.org/LDP/abs/html/exitcodes.html The GNU recommendations stem from and expand upon the standard C/C++ library (stdlibc) definitions, while also suggesting some best-practice conventions which happen to prevent exit status code collisions with bash, and probably other shells. The re-allocated codes are now mapped to constant values, set in *application/config/constants.php*, and used throughout the CodeIgniter core. They would additionally be used in *index.php*, but the constants file hasn't been loaded at that point, so the integer values are used instead, and a comment follows each such use with amplifying information on why that particular value was selected. Finally, the errors documentation has been updated accordingly. Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
Diffstat (limited to 'system/core')
-rw-r--r--system/core/CodeIgniter.php2
-rw-r--r--system/core/Common.php16
-rw-r--r--system/core/Exceptions.php2
-rw-r--r--system/core/Input.php2
-rw-r--r--system/core/Output.php2
5 files changed, 14 insertions, 10 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 5a872ef21..8f5271add 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -188,7 +188,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
if ($EXT->call_hook('cache_override') === FALSE
&& $OUT->_display_cache($CFG, $URI) === TRUE)
{
- exit(0);
+ exit(EXIT_SUCCESS);
}
/*
diff --git a/system/core/Common.php b/system/core/Common.php
index 3cd97dc2e..479f0da7f 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -177,7 +177,7 @@ if ( ! function_exists('load_class'))
// self-referencing loop with the Exceptions class
set_status_header(503);
echo 'Unable to locate the specified class: '.$class.'.php';
- exit(2);
+ exit(EXIT_UNK_CLASS);
}
// Keep track of what we just loaded
@@ -251,7 +251,7 @@ if ( ! function_exists('get_config'))
{
set_status_header(503);
echo 'The configuration file does not exist.';
- exit(1);
+ exit(EXIT_CONFIG);
}
// Does the $config array exist in the file?
@@ -259,7 +259,7 @@ if ( ! function_exists('get_config'))
{
set_status_header(503);
echo 'Your config file does not appear to be formatted correctly.';
- exit(1);
+ exit(EXIT_CONFIG);
}
// Are any values being dynamically replaced?
@@ -374,12 +374,16 @@ if ( ! function_exists('show_error'))
$status_code = abs($status_code);
if ($status_code < 100)
{
- $exit_status = $status_code + 28;
+ $exit_status = $status_code + EXIT__AUTO_MIN;
+ if ($exit_status > EXIT__AUTO_MAX)
+ {
+ $exit_status = EXIT_FAILURE;
+ }
$status_code = 500;
}
else
{
- $exit_status = 27;
+ $exit_status = EXIT_FAILURE;
}
$_error =& load_class('Exceptions', 'core');
@@ -407,7 +411,7 @@ if ( ! function_exists('show_404'))
{
$_error =& load_class('Exceptions', 'core');
$_error->show_404($page, $log_error);
- exit(4);
+ exit(EXIT_UNK_FILE);
}
}
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index f799d6027..423387ff9 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(4);
+ exit(EXIT_UNK_FILE);
}
// --------------------------------------------------------------------
diff --git a/system/core/Input.php b/system/core/Input.php
index 904f4d6e9..8d491e055 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -746,7 +746,7 @@ class CI_Input {
{
set_status_header(503);
echo 'Disallowed Key Characters.';
- exit(6);
+ exit(EXIT_USER_INPUT);
}
// Clean UTF-8 if supported
diff --git a/system/core/Output.php b/system/core/Output.php
index d4abe871d..1025703dc 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -696,7 +696,7 @@ class CI_Output {
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']))
{
$this->set_status_header(304);
- exit(0);
+ exit(EXIT_SUCCESS);
}
else
{