summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornisheeth-barthwal <nisheeth.barthwal@nbaztec.co.in>2013-03-23 06:23:51 +0100
committernisheeth-barthwal <nisheeth.barthwal@nbaztec.co.in>2013-03-23 06:23:51 +0100
commita5bcfb1d291d42521b0dc420b1b501c36710277d (patch)
treef5ec3aa630a5fc3bc5d5e4f0a023d8a28c7e4086
parenta945d078d769f00410d10d10b9fdac3ea2e55b45 (diff)
Removed $recurse parameter in lieu of auto parsing. Changed "provision" entry.
-rw-r--r--system/core/Input.php32
-rw-r--r--system/helpers/form_helper.php2
-rw-r--r--user_guide_src/source/changelog.rst2
3 files changed, 15 insertions, 21 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index ffe7b4d27..7424a003a 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -149,10 +149,9 @@ class CI_Input {
* @param array &$array $_GET, $_POST, $_COOKIE, $_SERVER, etc.
* @param string $index Index for item to be fetched from $array
* @param bool $xss_clean Whether to apply XSS filtering
- * @param bool $recurse Whether to recurse into arrays via nested keys
* @return mixed
*/
- protected function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE, $recurse = FALSE)
+ protected function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
{
$value = NULL;
@@ -160,9 +159,8 @@ class CI_Input {
{
$value = $array[$index];
}
- else if($recurse)
+ else if(preg_match('/\[[^]]*\]$/', $index)) // Does the index contain array notation
{
- // We couldn't find the $field as a simple key, so try the nested notation
$key = $index;
$container = $array;
@@ -211,10 +209,9 @@ class CI_Input {
*
* @param string $index Index for item to be fetched from $_GET
* @param bool $xss_clean Whether to apply XSS filtering
- * @param bool $recurse Whether to recurse into arrays via nested keys
* @return mixed
*/
- public function get($index = NULL, $xss_clean = FALSE, $recurse = FALSE)
+ public function get($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL)
@@ -229,12 +226,12 @@ class CI_Input {
// loop through the full _GET array
foreach (array_keys($_GET) as $key)
{
- $get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean, $recurse);
+ $get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean);
}
return $get;
}
- return $this->_fetch_from_array($_GET, $index, $xss_clean, $recurse);
+ return $this->_fetch_from_array($_GET, $index, $xss_clean);
}
// --------------------------------------------------------------------
@@ -244,10 +241,9 @@ class CI_Input {
*
* @param string $index Index for item to be fetched from $_POST
* @param bool $xss_clean Whether to apply XSS filtering
- * @param bool $recurse Whether to recurse into arrays via nested keys
* @return mixed
*/
- public function post($index = NULL, $xss_clean = FALSE, $recurse = FALSE)
+ public function post($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL)
@@ -262,12 +258,12 @@ class CI_Input {
// Loop through the full _POST array and return it
foreach (array_keys($_POST) as $key)
{
- $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean, $recurse);
+ $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
}
return $post;
}
- return $this->_fetch_from_array($_POST, $index, $xss_clean, $recurse);
+ return $this->_fetch_from_array($_POST, $index, $xss_clean);
}
// --------------------------------------------------------------------
@@ -277,14 +273,13 @@ class CI_Input {
*
* @param string $index Index for item to be fetched from $_POST or $_GET
* @param bool $xss_clean Whether to apply XSS filtering
- * @param bool $recurse Whether to recurse into arrays via nested keys
* @return mixed
*/
- public function get_post($index = '', $xss_clean = FALSE, $recurse = FALSE)
+ public function get_post($index = '', $xss_clean = FALSE)
{
return isset($_POST[$index])
- ? $this->post($index, $xss_clean, $recurse)
- : $this->get($index, $xss_clean, $recurse);
+ ? $this->post($index, $xss_clean)
+ : $this->get($index, $xss_clean);
}
// --------------------------------------------------------------------
@@ -294,12 +289,11 @@ class CI_Input {
*
* @param string $index Index for item to be fetched from $_COOKIE
* @param bool $xss_clean Whether to apply XSS filtering
- * @param bool $recurse Whether to recurse into arrays via nested keys
* @return mixed
*/
- public function cookie($index = '', $xss_clean = FALSE, $recurse = FALSE)
+ public function cookie($index = '', $xss_clean = FALSE)
{
- return $this->_fetch_from_array($_COOKIE, $index, $xss_clean, $recurse);
+ return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
}
// --------------------------------------------------------------------
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index d2c22b05c..2238af92a 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -647,7 +647,7 @@ if ( ! function_exists('set_value'))
return form_prep($OBJ->set_value($field, $default), $is_textarea);
}
- if (FALSE !== ($OBJ =& _get_input_object()) && ($value = $OBJ->post($field, FALSE, TRUE)))
+ if (FALSE !== ($OBJ =& _get_input_object()) && ($value = $OBJ->post($field, FALSE)))
{
return form_prep($value, $is_textarea);
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index bc74973e0..6ef08c1a9 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -304,7 +304,7 @@ Release Date: Not Released
- Changed method ``valid_ip()`` to use PHP's native ``filter_var()`` function.
- Changed internal method ``_sanitize_globals()`` to skip enforcing reversal of *register_globals* in PHP 5.4+, where this functionality no longer exists.
- Changed methods ``get()``, ``post()``, ``get_post()``, ``cookie()``, ``server()``, ``user_agent()`` to return NULL instead of FALSE when no value is found.
- - Added provision for using array notation for keys.
+ - Changed method ``_fetch_from_array()`` to parse array notation in field name.
- :doc:`Common functions <general/common_functions>` changes include:
- Added function :php:func:`get_mimes()` to return the *application/config/mimes.php* array.
- Added support for HTTP code 303 ("See Other") in :php:func:`set_status_header()`.