From eaf0f07766bd059e563dbf0146ae73e7d4d37642 Mon Sep 17 00:00:00 2001 From: Gabriel P <16049869+gabpnr@users.noreply.github.com> Date: Tue, 20 Mar 2018 01:58:21 +0100 Subject: [PATCH 1/3] Fix issue 966 dot array in old() function Signed-off-by: Gabriel P <16049869+gabpnr@users.noreply.github.com> --- system/HTTP/IncomingRequest.php | 16 +++++++++++++++- .../source/general/common_functions.rst | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) mode change 100644 => 100755 system/HTTP/IncomingRequest.php mode change 100644 => 100755 user_guide_src/source/general/common_functions.rst diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php old mode 100644 new mode 100755 index 54f7e211f0bf..ddc5b24dd5a1 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -466,7 +466,7 @@ public function getUserAgent() /** * Attempts to get old Input data that has been flashed to the session * with redirect_with_input(). It first checks for the data in the old - * POST data, then the old GET data. + * POST data, then the old GET data and finally check for dot arrays * * @param string $key * @@ -490,6 +490,20 @@ public function getOldInput(string $key) { return $_SESSION['_ci_old_input']['get'][$key]; } + + helper('array'); + + // Check for an array value in POST. + if (dot_array_search($key, $_SESSION['_ci_old_input']['post'])) + { + return dot_array_search($key, $_SESSION['_ci_old_input']['post']); + } + + // Check for an array value in GET. + if (dot_array_search($key, $_SESSION['_ci_old_input']['get'])) + { + return dot_array_search($key, $_SESSION['_ci_old_input']['get']); + } } /** diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst old mode 100644 new mode 100755 index 61faa1f801b9..de3d760b905a --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -100,6 +100,8 @@ Service Accessors // In the view + // Or with arrays + .. note:: If you are using the :doc:`form helper `, this feature is built-in. You only need to use this function when not using the form helper. From 4457529a8be282b6fc36faa05f0ea287f734343f Mon Sep 17 00:00:00 2001 From: Gabriel P <16049869+gabpnr@users.noreply.github.com> Date: Tue, 20 Mar 2018 02:17:40 +0100 Subject: [PATCH 2/3] Fix issue 966 dot array in old() function Signed-off-by: Gabriel P <16049869+gabpnr@users.noreply.github.com> --- system/HTTP/IncomingRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index ddc5b24dd5a1..29beb766a21d 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -494,13 +494,13 @@ public function getOldInput(string $key) helper('array'); // Check for an array value in POST. - if (dot_array_search($key, $_SESSION['_ci_old_input']['post'])) + if (isset($_SESSION['_ci_old_input']['post']) && dot_array_search($key, $_SESSION['_ci_old_input']['post'])) { return dot_array_search($key, $_SESSION['_ci_old_input']['post']); } // Check for an array value in GET. - if (dot_array_search($key, $_SESSION['_ci_old_input']['get'])) + if (isset($_SESSION['_ci_old_input']['get']) && dot_array_search($key, $_SESSION['_ci_old_input']['get'])) { return dot_array_search($key, $_SESSION['_ci_old_input']['get']); } From cd31a89a10c29d7d8bf795b067a974f954ae6499 Mon Sep 17 00:00:00 2001 From: Gabriel P <16049869+gabpnr@users.noreply.github.com> Date: Tue, 20 Mar 2018 09:11:18 +0100 Subject: [PATCH 3/3] Fix issue 966 dot array in old() function Signed-off-by: Gabriel P <16049869+gabpnr@users.noreply.github.com> --- system/HTTP/IncomingRequest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 29beb766a21d..1d76ad9aacbf 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -494,15 +494,23 @@ public function getOldInput(string $key) helper('array'); // Check for an array value in POST. - if (isset($_SESSION['_ci_old_input']['post']) && dot_array_search($key, $_SESSION['_ci_old_input']['post'])) + if (isset($_SESSION['_ci_old_input']['post'])) { - return dot_array_search($key, $_SESSION['_ci_old_input']['post']); + $value = dot_array_search($key, $_SESSION['_ci_old_input']['post']); + if ( ! is_null($value)) + { + return $value; + } } // Check for an array value in GET. - if (isset($_SESSION['_ci_old_input']['get']) && dot_array_search($key, $_SESSION['_ci_old_input']['get'])) + if (isset($_SESSION['_ci_old_input']['get'])) { - return dot_array_search($key, $_SESSION['_ci_old_input']['get']); + $value = dot_array_search($key, $_SESSION['_ci_old_input']['get']); + if ( ! is_null($value)) + { + return $value; + } } }