-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Old() - Seems to have an issue with retrieving array values #1492
Comments
I just tried "git pull" to pull latest changes and I can see that it pulled in System/Common.php and System/HTTP/IncomingRequest.php plus some test files - however, I am unsure but it seemed to have an affect on redirect(). Any calls to redirect just end up with a blank page? |
@daljit3 Can you provide an example of a redirect that ends up with a blank page? |
@jim-parry Thanks for getting back to me quickly. Please take a look at this method below. Yesterday, all the code was working fine until I found the bug above. Today, I saw your email that it has been fixed. I did git pull so that I can check if it was fixed. I tried to login to my site on my local but it gave me a blank page after submitting my login credentials. I manually changed the url to home page and I could see that it did log me in. I tried to logout where all I have is the code below and it just gives me a blank page without redirecting.
|
When doing redirects, you should always return the redirect, like so:
|
I also tried |
@lonnieezell yes when I downloaded the very first release of CI4, I did have a |
@daljit3 Gotcha. It was designed so that you have to do a return, but sounds like there's an issue there. I know they've made some changes to redirects in the last couple of days trying to clean things up, and I've been slammed with the day job for the past bit so I'm not 100% in the loop on the changes here. I'll let @jim-parry continue on with this one. |
Yes - I can confirm there is an issue with redirects. I just downloaded a new copy of CI4-develop and I could see welcome message to confirm everything working fine. Then I made these modifications below to the Home controller. If I try
|
I will revert the changes I made to "fix old()" and start from there. |
Done, and I will comment further on the other bug report. |
Solution confirmed, phew |
name: Bug report
about: Help us improve the framework by reporting bugs!
Describe the bug
My input field is named as "locations[]". When the form failed validation - I tried to retrieve it as
$locations = old('locations');
Which throws up an error -strpos() expects parameter 1 to be string, array given - BASEPATH/Common.php at line 786
The line 786 is in old() method in System/Common.php is
// If the result was serialized array or string, then unserialize it for use... if (strpos($value, 'a:') === 0 || strpos($value, 's:') === 0) { $value = unserialize($value); }
Here are the full methods from all the files which I think are related to this issue.
You can see the
$value
is being parsed through$request->getOldInput($key);
in this old() method. There isn't any where I can see the arrays in POST data being serialised as I looked into WithInput() method too.** File system/HTTP/IncomingRequest.php **
** File System/HTTP/RedirectResponse.php **
CodeIgniter 4 version
4.0.0-alpha.2 Released
Affected module(s)
System/Common.php, System/HTTP/IncomingRequest.php, System/HTTP/RedirectResponse.php
Expected behavior, and steps to reproduce if appropriate
It should return full array.
The text was updated successfully, but these errors were encountered: