summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2012-05-23 19:37:24 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2012-05-23 19:42:04 +0200
commit55a6ddb0c7bab1149bb1ddfa3a1aff46612c91d4 (patch)
tree5840dd5451c53c5fc01509288c4484d5189a66a1
parent37294771ef8cdb0c2d4834783ad79a6bdbc96d77 (diff)
Input, Session and Cookie get's will return NULL.
Read more about this change here: http://codeigniter.com/forums/viewthread/215833
-rwxr-xr-xsystem/core/Input.php4
-rwxr-xr-xsystem/core/URI.php18
-rw-r--r--system/libraries/Session.php6
-rw-r--r--tests/codeigniter/core/Input_test.php18
-rw-r--r--user_guide_src/source/libraries/input.rst17
-rw-r--r--user_guide_src/source/libraries/uri.rst2
6 files changed, 30 insertions, 35 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index e916ac66d..97be9e690 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -135,7 +135,7 @@ class CI_Input {
{
if ( ! isset($array[$index]))
{
- return FALSE;
+ return NULL;
}
if ($xss_clean === TRUE)
@@ -659,7 +659,7 @@ class CI_Input {
if ( ! isset($this->headers[$index]))
{
- return FALSE;
+ return NULL;
}
return ($xss_clean === TRUE)
diff --git a/system/core/URI.php b/system/core/URI.php
index e66cb6dc5..a9432e05d 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -358,10 +358,10 @@ class CI_URI {
* This function returns the URI segment based on the number provided.
*
* @param int
- * @param bool
+ * @param mixed
* @return string
*/
- public function segment($n, $no_result = FALSE)
+ public function segment($n, $no_result = NULL)
{
return isset($this->segments[$n]) ? $this->segments[$n] : $no_result;
}
@@ -376,10 +376,10 @@ class CI_URI {
* same result as $this->segment()
*
* @param int
- * @param bool
+ * @param mixed
* @return string
*/
- public function rsegment($n, $no_result = FALSE)
+ public function rsegment($n, $no_result = NULL)
{
return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result;
}
@@ -462,7 +462,7 @@ class CI_URI {
{
return (count($default) === 0)
? array()
- : array_fill_keys($default, FALSE);
+ : array_fill_keys($default, NULL);
}
$segments = array_slice($this->$segment_array(), ($n - 1));
@@ -477,7 +477,7 @@ class CI_URI {
}
else
{
- $retval[$seg] = FALSE;
+ $retval[$seg] = NULL;
$lastval = $seg;
}
@@ -490,7 +490,7 @@ class CI_URI {
{
if ( ! array_key_exists($val, $retval))
{
- $retval[$val] = FALSE;
+ $retval[$val] = NULL;
}
}
}
@@ -511,7 +511,7 @@ class CI_URI {
public function assoc_to_uri($array)
{
$temp = array();
- foreach ( (array) $array as $key => $val)
+ foreach ((array) $array as $key => $val)
{
$temp[] = $key;
$temp[] = $val;
@@ -644,7 +644,7 @@ class CI_URI {
*/
public function ruri_string()
{
- return '/'.implode('/', $this->rsegment_array());
+ return implode('/', $this->rsegment_array());
}
}
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 783109a60..4d6aa0ce8 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -276,7 +276,7 @@ class CI_Session {
$session = $this->CI->input->cookie($this->sess_cookie_name);
// No cookie? Goodbye cruel world!...
- if ($session === FALSE)
+ if ($session === NULL)
{
log_message('debug', 'A session cookie was not found.');
return FALSE;
@@ -586,7 +586,7 @@ class CI_Session {
*/
public function userdata($item)
{
- return isset($this->userdata[$item]) ? $this->userdata[$item] : FALSE;
+ return isset($this->userdata[$item]) ? $this->userdata[$item] : NULL;
}
// --------------------------------------------------------------------
@@ -715,7 +715,7 @@ class CI_Session {
{
// 'old' flashdata gets removed. Here we mark all
// flashdata as 'new' to preserve it from _flashdata_sweep()
- // Note the function will return FALSE if the $key
+ // Note the function will return NULL if the $key
// provided cannot be found
$value = $this->userdata($this->flashdata_key.':old:'.$key);
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index fd0576e38..a066d9960 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -28,11 +28,13 @@ class Input_test extends CI_TestCase {
$this->assertTrue( ! $this->input->get());
$this->assertTrue( ! $this->input->get('foo'));
- $this->assertTrue($this->input->get() == FALSE);
- $this->assertTrue($this->input->get('foo') == FALSE);
+ // Test we're getting empty results
+ $this->assertTrue($this->input->get() == NULL);
+ $this->assertTrue($this->input->get('foo') == NULL);
- $this->assertTrue($this->input->get() === FALSE);
- $this->assertTrue($this->input->get('foo') === FALSE);
+ // Test new 3.0 behaviour for non existant results (used to be FALSE)
+ $this->assertTrue($this->input->get() === NULL);
+ $this->assertTrue($this->input->get('foo') === NULL);
}
// --------------------------------------------------------------------
@@ -68,11 +70,11 @@ class Input_test extends CI_TestCase {
$this->assertTrue( ! $this->input->post());
$this->assertTrue( ! $this->input->post('foo'));
- $this->assertTrue($this->input->post() == FALSE);
- $this->assertTrue($this->input->post('foo') == FALSE);
+ $this->assertTrue($this->input->post() == NULL);
+ $this->assertTrue($this->input->post('foo') == NULL);
- $this->assertTrue($this->input->post() === FALSE);
- $this->assertTrue($this->input->post('foo') === FALSE);
+ $this->assertTrue($this->input->post() === NULL);
+ $this->assertTrue($this->input->post('foo') === NULL);
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index 1f2ea650a..432bac3c7 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -18,7 +18,7 @@ The security filtering function is called automatically when a new
:doc:`controller <../general/controllers>` is invoked. It does the
following:
-- If $config['allow_get_array'] is FALSE(default is TRUE), destroys
+- If $config['allow_get_array'] is FALSE (default is TRUE), destroys
the global GET array.
- Destroys all global variables in the event register_globals is
turned on.
@@ -53,14 +53,7 @@ false (boolean) if not. This lets you conveniently use data without
having to test whether an item exists first. In other words, normally
you might do something like this::
- if ( ! isset($_POST['something']))
- {
- $something = FALSE;
- }
- else
- {
- $something = $_POST['something'];
- }
+ $something = isset($_POST['something']) ? $_POST['something'] : NULL;
With CodeIgniter's built in functions you can simply do this::
@@ -95,7 +88,7 @@ To return an array of all POST items call without any parameters.
To return all POST items and pass them through the XSS filter set the
first parameter NULL while setting the second parameter to boolean;
-The function returns FALSE (boolean) if there are no items in the POST.
+The function returns NULL if there are no items in the POST.
::
@@ -115,7 +108,7 @@ To return an array of all GET items call without any parameters.
To return all GET items and pass them through the XSS filter set the
first parameter NULL while setting the second parameter to boolean;
-The function returns FALSE (boolean) if there are no items in the GET.
+The function returns NULL if there are no items in the GET.
::
@@ -210,7 +203,7 @@ the cookie you are looking for (including any prefixes)::
cookie('some_cookie');
-The function returns FALSE (boolean) if the item you are attempting to
+The function returns NULL if the item you are attempting to
retrieve does not exist.
The second optional parameter lets you run the data through the XSS
diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst
index ee60b77d7..cdd76e322 100644
--- a/user_guide_src/source/libraries/uri.rst
+++ b/user_guide_src/source/libraries/uri.rst
@@ -25,7 +25,7 @@ The segment numbers would be this:
#. metro
#. crime_is_up
-By default the function returns FALSE (boolean) if the segment does not
+By default the function returns NULL if the segment does not
exist. There is an optional second parameter that permits you to set
your own default value if the segment is missing. For example, this
would tell the function to return the number zero in the event of