summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2013-11-12 16:04:55 +0100
committerAndrey Andreev <narf@devilix.net>2013-11-12 16:04:55 +0100
commitf964b16f3db95d655420dfae2012ee9fbb98a1a8 (patch)
treea3a2acf87bf15604da653c67e1a348097225f817 /user_guide_src/source
parent35e3b0bc4f723b938160da87aeb5ad9e054507c4 (diff)
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
Diffstat (limited to 'user_guide_src/source')
-rw-r--r--user_guide_src/source/changelog.rst2
-rw-r--r--user_guide_src/source/general/cli.rst2
-rw-r--r--user_guide_src/source/general/common_functions.rst13
-rw-r--r--user_guide_src/source/helpers/date_helper.rst2
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst24
-rw-r--r--user_guide_src/source/libraries/input.rst3
6 files changed, 44 insertions, 2 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5fc86b1b5..23fd95893 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -396,6 +396,7 @@ Release Date: Not Released
- Added method ``post_get()`` and changed ``get_post()`` to search in GET data first. Both methods' names now properly match their GET/POST data search priorities.
- Changed method ``_fetch_from_array()`` to parse array notation in field name.
- Added an option for ``_clean_input_keys()`` to return FALSE instead of terminating the whole script.
+ - Deprecated the ``is_cli_request()`` method, it is now an alias for the new :php:func:`is_cli()` common function.
- :doc:`Common functions <general/common_functions>` changes include:
@@ -404,6 +405,7 @@ Release Date: Not Released
- Removed redundant conditional to determine HTTP server protocol in :php:func:`set_status_header()`.
- Changed ``_exception_handler()`` to respect php.ini *display_errors* setting.
- Added function :php:func:`is_https()` to check if a secure connection is used.
+ - Added function :php:func:`is_cli()` to replace the ``CI_Input::is_cli_request()`` method.
- Added function :php:func:`function_usable()` to check if a function exists and is not disabled by `Suhosin <http://www.hardened-php.net/suhosin/>`.
- Removed the third (`$php_error`) from function :php:func:`log_message()`.
diff --git a/user_guide_src/source/general/cli.rst b/user_guide_src/source/general/cli.rst
index 4145d5ccc..4f3b07d9e 100644
--- a/user_guide_src/source/general/cli.rst
+++ b/user_guide_src/source/general/cli.rst
@@ -23,7 +23,7 @@ but they are not always obvious.
- Run your cron-jobs without needing to use *wget* or *curl*
- Make your cron-jobs inaccessible from being loaded in the URL by
- checking for ``$this->input->is_cli_request()``
+ checking the return value of :func:`is_cli()`.
- Make interactive "tasks" that can do things like set permissions,
prune cache folders, run backups, etc.
- Integrate with other applications in other languages. For example, a
diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst
index e085ef808..2dfec9cc0 100644
--- a/user_guide_src/source/general/common_functions.rst
+++ b/user_guide_src/source/general/common_functions.rst
@@ -173,6 +173,19 @@ is_https()
Returns TRUE if a secure (HTTPS) connection is used and FALSE
in any other case (including non-HTTP requests).
+is_cli()
+========
+
+.. php:function:: is_cli()
+
+ :returns: bool
+
+Returns TRUE if the application is run through the command line
+and FALSE if not.
+
+.. note:: This function checks both if the ``PHP_SAPI`` value is 'cli'
+ or if the ``STDIN`` constant is defined.
+
function_usable()
=================
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index 5dfee8b48..8126eba6c 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -80,7 +80,7 @@ Example::
$time = time();
echo standard_date($format, $time);
-.. note:: This function is DEPRECATED.Use the native ``date()`` combined with
+.. note:: This function is DEPRECATED. Use the native ``date()`` combined with
`DateTime's format constants
<http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_
instead:
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index e8fdd0b15..8f9cc1bdc 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -457,4 +457,28 @@ then you can now just access the properties instead::
$this->router->method;
.. note:: Those methods are still available, but you're strongly encouraged to remove their usage
+ sooner rather than later.
+
+Input library method is_cli_request()
+=====================================
+
+Calls to the ``CI_Input::is_cli_request()`` method are necessary at many places
+in the CodeIgniter internals and this is often before the :doc:`Input Library
+<../libraries/input>` is loaded. Because of that, it is being replaced by a common
+function named :php:func:`is_cli()` and this method is now just an alias.
+
+The new function is both available at all times for you to use and shorter to type.
+
+::
+
+ // Old
+ $this->input->is_cli_request();
+
+ // New
+ is_cli();
+
+``CI_Input::is_cli_request()`` is now now deprecated and scheduled for removal in
+CodeIgniter 3.1+.
+
+.. note:: This method is still available, but you're strongly encouraged to remove its usage
sooner rather than later. \ No newline at end of file
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index fb245d7cd..b58ed2f0d 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -315,6 +315,9 @@ see if PHP is being run on the command line.
$this->input->is_cli_request()
+.. note:: This method is DEPRECATED and is now just an alias for the
+ :php:func:`is_cli()` function.
+
$this->input->method()
======================