-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: getGetPost() and getPostGet() when index is null #6675
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
Conversation
I think this fix is okay and consistent with the current implementation. But when do you use the methods without index? |
I started experimenting with Controlled Cells, and this approach seemed to be appropriate to get the values I wanted before filtering everything. And that's how I discovered this bug. To be fair, I can't recall that I used this method without an index before, but I can imagine it can be helpful sometimes, especially when we want to create some wrapper around other libraries. I think Datatables would be a good example. Of course, we can always debate that it is better to refer to specific indexes (that we should know), but I think the choice should be left to the developer, and the method should do what it advertises. |
I'm not sure using these methods is really no harm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is worth more discussion. getVar()
reads as follows:
To return an array of all POST items call without any parameters.
So sets some precedence for returning just $_POST. Both getPostGet()
and getGetPost()
state:
Returns: $_POST if no parameters supplied, otherwise the POST value if found, or null if not
Which is obviously wrong because it never mentions $_GET
, but if the goal is to bring the code in line with the UG I think we need to decide what that is first. Alternatively, if we would rather define appropriate behavior for these then it would be better to do that before setting a precedent.
Good catch. It certainly does not seem to describe the correct behavior when no parameters are supplied.
I think this PR's behavior is logical. So we should fix the UG like that. |
I think that the When it comes to the |
… the user guide when no index is specified
I have updated the description, so now there should be no doubt about how these methods work... although IMO there should have been no doubt before either (except for the incorrect description for the return). As kenjis mentioned, the UG states:
And we all know how |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with that. Thanks for the UG update!
Refactor request, maybe v5: either make input variables a dedicated class ($request->vars->post('foo')
) or just collapse all of these into 1-2 methods with parameters.
Description
This PR fixes the problem below:
Basically, we return only one stream:
getPostGet()
method -POST
arraygetGetPost()
method -GET
arrayAnd that's fine when the
index
is specified.But not when
index
isnull
. We should check both streams for values and return them all with priority forGET
orPOST
values - depending on the used method.Checklist: