Bug #19182
closedWrong getData behaviour in "foo|bar" case
0%
Description
What about problem?
We have "foo" data in both(!) GET and POST arrays. But "foo[bar]" data we have only in GET array. We want to get "foo[bar]" element. We can't do that.
Why?
Responsible for that function (now t3lib_div::_GP) looks for "foo" key first in POST array and if founded immediatly returns it. So if we have "foo[bar]" in GET, we have void result.
File: class.tslib_content.php
Line: 4848
Advise for quick solution: replace t3lib_div::_GP with t3lib_div::GParrayMerged
(issue imported from #M9100)
Files
Updated by Benni Mack over 16 years ago
hey
wouldn't it make more sense to have a GPvar and additionally GETvar and POSTvar for that?
Updated by Petro Boychuk over 16 years ago
As far as I know there are separate methods to get GET and POST vars in t3lib_div.
Bu the problem is that if there are same first level names in both $_GET and $_POST superglobal arrays than data from $_POST array will be returned.
Example:
$_GET = array(
'foo' => array(
'bar' => '1'
)
)
$_POST = array(
'foo' => array(
'bar2' => '2'
)
)
So result of t3lib_div::GPvar('foo'); will be
array (
'bar' => '1'
)
But expected value (as far as I understand it) must be
array(
'bar' => '1',
'bar2' => '2'
)
I use (and it seems that core too) this function to get data when it is not known how data arrives, from GET or POST, or maybe both.
Updated by Benni Mack over 16 years ago
Hey Petro,
can you create a patch for this and send it to the core list?
Thanks
Updated by Myroslav Holyak over 16 years ago
Changes in _GP function caused wrong work of typo3 backend and oteher extensinos (sr_fe_register at least). So only way to patch i see is to replace call _GP function by GParrayMerged in class.tslib_content.php
There is one problem: function GParrayMerged is deprecated. Interesting to know why. It has the same "stripslash" sanitizing as _GP.
Please, remove my old patches
Updated by Benni Mack over 16 years ago
Hey,
I see, GParrayMerged is deprecated. So for me the one and only solution would be to have not just TSFE and GP and such, but also GET and POST as options
[globalVar = GET:foo|bar = mymatch]
[globalVar = POST:foo|bar = mymatch]
Anyway, all the changes need to happen in t3lib/class.t3lib_matchcondition.php, as there is the change we need, not in all _GP occurrences.
Updated by Dmitry Dulepov about 16 years ago
No change to t3lib_div::_GP() because it impacts compatibility.
Use global:_REQUEST if you really have too. Or better change your code to have that parameter only in one place.
I recommend closing this bug with "won't fix". We should not make workarounds to support bad architecture issues (same var in both GET and POST).
Updated by Myroslav Holyak about 16 years ago
Why "same var"? GET[foo][bar] and POST[foo][bar1] isn't the same var. It can be if extension submit form and at the same time had some parameters in address bar. Of course we can transfer all by POST and have "all variables in the same place" in that way. On my opinion it must be developer decision and API should give secure possibility to do that.
Updated by Benni Mack over 14 years ago
these methods have changed to all use "array-merged-recursive-overrule". Does this bug still exists for you?
Updated by Myroslav Holyak over 14 years ago
No, it's gone away . Thank you, nice choice of solution.