Some optimizations & polishing following PR #3381
diff --git a/system/core/Input.php b/system/core/Input.php
index 11b2e94..d1353e9 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -156,8 +156,13 @@
*/
protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = NULL)
{
+ is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
+
// If $index is NULL, it means that the whole $array is requested
- if ($index === NULL)
+ isset($index) OR $index = array_keys($array);
+
+ // allow fetching multiple keys at once
+ if (is_array($index))
{
$output = array();
foreach (array_keys($array) as $key)
@@ -168,20 +173,6 @@
return $output;
}
- // allow fetching multiple keys at once
- if (is_array($index))
- {
- $output = array();
- foreach ($index as $var)
- {
- $output[$var] = $this->_fetch_from_array($array, $var, $xss_clean);
- }
-
- return $output;
- }
-
- is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
-
if (isset($array[$index]))
{
$value = $array[$index];
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 711120a..f01ff8a 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -473,7 +473,7 @@
- Changed default value of the ``$xss_clean`` parameter to NULL for all methods that utilize it, the default value is now determined by the ``$config['global_xss_filtering']`` setting.
- 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.
- - Changed method ``_fetch_from_array()`` to allow retrieving multiple fields at once by passing $index as an array.
+ - Changed method ``_fetch_from_array()`` to allow retrieving multiple fields at once.
- 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 :func:`is_cli()` common function.
- Added an ``$xss_clean`` parameter to method ``user_agent()`` and removed the ``$user_agent`` property.
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index 4df7629..1123471 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -208,7 +208,7 @@
.. method:: cookie([$index = NULL[, $xss_clean = NULL]])
- :param mixed $index: COOKIE parameter name
+ :param mixed $index: COOKIE name
:param bool $xss_clean: Whether to apply XSS filtering
:returns: $_COOKIE if no parameters supplied, otherwise the COOKIE value if found or NULL if not
:rtype: mixed
@@ -219,7 +219,7 @@
$this->input->cookie('some_cookie');
$this->input->cookie('some_cookie, TRUE); // with XSS filter
- To return an array of multiple cookie parameters, pass all the required keys
+ To return an array of multiple cookie values, pass all the required keys
as an array.
::
$this->input->cookie(array('some_cookie', 'some_cookie2'));
@@ -236,7 +236,7 @@
$this->input->server('some_data');
- To return an array of multiple server parameters, pass all the required keys
+ To return an array of multiple ``$_SERVER`` values, pass all the required keys
as an array.
::
$this->input->server(array('SERVER_PROTOCOL', 'REQUEST_URI'));