Merge pull request #2598 from vlakoff/develop

Input class: change behavior of get_post() method, add post_get() method
diff --git a/system/core/Input.php b/system/core/Input.php
index 1e67ce1..24e21ea 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -261,7 +261,7 @@
 	 * @param	bool	$xss_clean	Whether to apply XSS filtering
 	 * @return	mixed
 	 */
-	public function get_post($index = '', $xss_clean = FALSE)
+	public function post_get($index = '', $xss_clean = FALSE)
 	{
 		return isset($_POST[$index])
 			? $this->post($index, $xss_clean)
@@ -271,6 +271,22 @@
 	// --------------------------------------------------------------------
 
 	/**
+	 * Fetch an item from GET data with fallback to POST
+	 *
+	 * @param	string	$index		Index for item to be fetched from $_GET or $_POST
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
+	 * @return	mixed
+	 */
+	public function get_post($index = '', $xss_clean = FALSE)
+	{
+		return isset($_GET[$index])
+			? $this->get($index, $xss_clean)
+			: $this->post($index, $xss_clean);
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
 	 * Fetch an item from the COOKIE array
 	 *
 	 * @param	string	$index		Index for item to be fetched from $_COOKIE
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index 5cf25fe..0a98e55 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -82,11 +82,21 @@
 
 	// --------------------------------------------------------------------
 
-	public function test_get_post()
+	public function test_post_get()
 	{
 		$_SERVER['REQUEST_METHOD'] = 'POST';
 		$_POST['foo'] = 'bar';
 
+		$this->assertEquals('bar', $this->input->post_get('foo'));
+	}
+
+	// --------------------------------------------------------------------
+
+	public function test_get_post()
+	{
+		$_SERVER['REQUEST_METHOD'] = 'GET';
+		$_GET['foo'] = 'bar';
+
 		$this->assertEquals('bar', $this->input->get_post('foo'));
 	}
 
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 4a45a71..8498918 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -388,6 +388,7 @@
       -  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 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.
 
    -  :doc:`Common functions <general/common_functions>` changes include:
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index 8983558..e8fdd0b 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -181,15 +181,26 @@
    - element()
    - elements()
 
+********************************************************
+Step 11: Update usage of Input Class's get_post() method
+********************************************************
+
+Previously, the :doc:`Input Class <../libraries/input>` method ``get_post()``
+was searching first in POST data, then in GET data. This method has been
+modified so that it searches in GET then in POST, as its name suggests.
+
+A method has been added, ``post_get()``, which searches in POST then in GET, as
+``get_post()`` was doing before.
+
 ***********************************************************************
-Step 11: Check the calls to Directory Helper's directory_map() function
+Step 12: Update usage of Directory Helper's directory_map() function
 ***********************************************************************
 
 In the resulting array, directories now end with a trailing directory
 separator (i.e. a slash, usually).
 
 *************************************************************
-Step 12: Update usage of Database Forge's drop_table() method
+Step 13: Update usage of Database Forge's drop_table() method
 *************************************************************
 
 Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work
@@ -211,7 +222,7 @@
 	all drivers with the exception of ODBC.
 
 ***********************************************************
-Step 13: Change usage of Email library with multiple emails
+Step 14: Change usage of Email library with multiple emails
 ***********************************************************
 
 The :doc:`Email Library <../libraries/email>` will automatically clear the
@@ -226,7 +237,7 @@
  	}
 
 ***************************************************
-Step 14: Update your Form_validation language lines
+Step 15: Update your Form_validation language lines
 ***************************************************
 
 Two improvements have been made to the :doc:`Form Validation Library
@@ -257,7 +268,7 @@
 	later.
 
 ****************************************************************
-Step 15: Remove usage of (previously) deprecated functionalities
+Step 16: Remove usage of (previously) deprecated functionalities
 ****************************************************************
 
 In addition to the ``$autoload['core']`` configuration setting, there's a
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index 177f5cb..fb245d7 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -98,7 +98,7 @@
 $this->input->get()
 ===================
 
-This method is identical to the post method, only it fetches get data
+This method is identical to the POST method, only it fetches GET data
 ::
 
 	$this->input->get('some_data', TRUE);
@@ -116,18 +116,26 @@
 	$this->input->get(); // returns all GET items without XSS filtering
 
 
+$this->input->post_get()
+========================
+
+This method will search through both the POST and GET streams for
+data, looking first in POST, and then in GET::
+
+	$this->input->post_get('some_data', TRUE);
+
 $this->input->get_post()
 ========================
 
-This method will search through both the post and get streams for
-data, looking first in post, and then in get::
+This method will search through both the POST and GET streams for
+data, looking first in GET, and then in POST::
 
 	$this->input->get_post('some_data', TRUE);
 
 $this->input->cookie()
 ======================
 
-This method is identical to the post method, only it fetches cookie data
+This method is identical to the POST method, only it fetches cookie data
 ::
 
 	$this->input->cookie('some_cookie');