From 3b5b7f48848d098c6190781f8790a1b0dcb0217c Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Fri, 22 Feb 2013 19:17:56 -0700 Subject: 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 --- user_guide_src/source/general/errors.rst | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst index 8c941aadb..1d6f8120d 100644 --- a/user_guide_src/source/general/errors.rst +++ b/user_guide_src/source/general/errors.rst @@ -18,6 +18,15 @@ procedural interfaces that are available globally throughout the application. This approach permits error messages to get triggered without having to worry about class/function scoping. +CodeIgniter also returns a status code whenever a portion of the core +calls ``exit()``. This exit status code is separate from the HTTP status +code, and serves as a notice to other processes that may be watching of +whether the script completed successfully, or if not, what kind of +problem it encountered that caused it to abort. These values are +defined in *application/config/constants.php*. While exit status codes +are most useful in CLI settings, returning the proper code helps server +software keep track of your scripts and the health of your application. + The following functions let you generate errors: show_error() @@ -36,7 +45,12 @@ following error template:: application/errors/error_general.php The optional parameter ``$status_code`` determines what HTTP status -code should be sent with the error. +code should be sent with the error. If ``$status_code`` is less than 100, +the HTTP status code will be set to 500, and the exit status code will +be set to ``$status_code + EXIT__AUTO_MIN``. If that value is larger than +``EXIT__AUTO_MAX``, or if ``$status_code`` is 100 or higher, the exit +status code will be set to ``EXIT_FAILURE``. You can check in +*application/config/constants.php* for more detail. show_404() ========== @@ -53,8 +67,9 @@ the following error template:: application/errors/error_404.php The function expects the string passed to it to be the file path to the -page that isn't found. Note that CodeIgniter automatically shows 404 -messages if controllers are not found. +page that isn't found. The exit status code will be set to ``EXIT_UNK_FILE``. +Note that CodeIgniter automatically shows 404 messages if controllers are +not found. CodeIgniter automatically logs any ``show_404()`` calls. Setting the optional second parameter to FALSE will skip logging. -- cgit v1.2.3-24-g4f1b From 50dfe0175df02fe4aa243757bdf1b42fb9fc3169 Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Mon, 4 Mar 2013 02:05:20 -0700 Subject: Updated in accordance with feedback from @narfbg - Removed commented lists of constants from the three reference conventions, replacing each with the URLs at which more information can be found. - Renamed a few constants to more closely reflect CodeIgniter conventions. - Modified a couple of lines which were in violation of the CI Style Guide. Signed-off-by: Daniel Hunsaker --- user_guide_src/source/general/errors.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst index 1d6f8120d..441cedb80 100644 --- a/user_guide_src/source/general/errors.rst +++ b/user_guide_src/source/general/errors.rst @@ -49,7 +49,7 @@ code should be sent with the error. If ``$status_code`` is less than 100, the HTTP status code will be set to 500, and the exit status code will be set to ``$status_code + EXIT__AUTO_MIN``. If that value is larger than ``EXIT__AUTO_MAX``, or if ``$status_code`` is 100 or higher, the exit -status code will be set to ``EXIT_FAILURE``. You can check in +status code will be set to ``EXIT_ERROR``. You can check in *application/config/constants.php* for more detail. show_404() @@ -67,7 +67,7 @@ the following error template:: application/errors/error_404.php The function expects the string passed to it to be the file path to the -page that isn't found. The exit status code will be set to ``EXIT_UNK_FILE``. +page that isn't found. The exit status code will be set to ``EXIT_UNKNOWN_FILE``. Note that CodeIgniter automatically shows 404 messages if controllers are not found. -- cgit v1.2.3-24-g4f1b From b527bb5ebb262351aa3c9fd393d91b98c8fbee00 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 5 Mar 2013 21:58:49 +0100 Subject: Documentation: update reserved names list Added constants from 50dfe0175df02fe4aa243757bdf1b42fb9fc3169 (exit status codes) --- user_guide_src/source/general/reserved_names.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/general/reserved_names.rst b/user_guide_src/source/general/reserved_names.rst index d91292363..1ca3b608a 100644 --- a/user_guide_src/source/general/reserved_names.rst +++ b/user_guide_src/source/general/reserved_names.rst @@ -66,4 +66,14 @@ Constants - FOPEN_WRITE_CREATE - FOPEN_READ_WRITE_CREATE - FOPEN_WRITE_CREATE_STRICT -- FOPEN_READ_WRITE_CREATE_STRICT \ No newline at end of file +- FOPEN_READ_WRITE_CREATE_STRICT +- EXIT_SUCCESS +- EXIT_ERROR +- EXIT_CONFIG +- EXIT_UNKNOWN_FILE +- EXIT_UNKNOWN_CLASS +- EXIT_UNKNOWN_METHOD +- EXIT_USER_INPUT +- EXIT_DATABASE +- EXIT__AUTO_MIN +- EXIT__AUTO_MAX \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 9a6032d87f3911ec6fcaf23736545920198a8b04 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 5 Mar 2013 23:03:12 +0100 Subject: Documentation: another update to reserved names list Added missing user functions. Also fixed a typo in common_functions.rst. --- user_guide_src/source/general/common_functions.rst | 2 +- user_guide_src/source/general/reserved_names.rst | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 7917d3239..79bd9b459 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -31,7 +31,7 @@ version of PHP is lower than the supplied version number. is_really_writable() ==================== -.. php:function:: is_really_writeable($file) +.. php:function:: is_really_writable($file) :param string $file: File path :returns: bool diff --git a/user_guide_src/source/general/reserved_names.rst b/user_guide_src/source/general/reserved_names.rst index 1ca3b608a..ccc17d61b 100644 --- a/user_guide_src/source/general/reserved_names.rst +++ b/user_guide_src/source/general/reserved_names.rst @@ -25,15 +25,21 @@ your controller any of these: Functions --------- +- :php:func:`is_php()` - :php:func:`is_really_writable()` - ``load_class()`` +- ``is_loaded()`` - ``get_config()`` - :php:func:`config_item()` - :php:func:`show_error()` - :php:func:`show_404()` - :php:func:`log_message()` +- :php:func:`set_status_header()` - :php:func:`get_mimes()` - :php:func:`html_escape()` +- :php:func:`remove_invisible_characters()` +- :php:func:`is_https()` +- :php:func:`function_usable()` - :php:func:`get_instance()` - ``_exception_handler()`` - ``_stringify_attributes()`` -- cgit v1.2.3-24-g4f1b From affc3bca4348071c792b6f08e6f88dede7e45266 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 6 Mar 2013 01:30:15 +0100 Subject: Fix a typo in changelog.rst This missing space was broking the link generation. --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 07dae1fdc..0e45a0e8f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -484,7 +484,7 @@ Bug fixes for 3.0 - Fixed a bug - :doc:`DB result ` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. - Fixed a bug (#73) - :doc:`Security Library ` method ``sanitize_filename()`` could be tricked by an XSS attack. - Fixed a bug (#2211) - :doc:`Migration Library ` extensions couldn't execute ``CI_Migration::__construct()``. -- Fixed a bug (#2255) - :doc:`Email Library ` didn't apply ``smtp_timeout``to socket reads and writes. +- Fixed a bug (#2255) - :doc:`Email Library ` didn't apply ``smtp_timeout`` to socket reads and writes. - Fixed a bug (#2239) - :doc:`Email Library ` improperly handled the Subject when used with ``bcc_batch_mode`` resulting in E_WARNING messages and an empty Subject. - Fixed a bug (#2234) - :doc:`Query Builder ` didn't reset JOIN cache for write-type queries. - Fixed a bug (#2298) - :doc:`Database Results ` method `next_row()` kept returning the last row, allowing for infinite loops. -- cgit v1.2.3-24-g4f1b