[TYPO3-core] RFC: #10040: define Default GET-vars
Rupert Germann
rupi at gmx.li
Tue Sep 1 18:48:28 CEST 2009
hi,
I think
if (!empty($this->config['config']['defaultGetVars.'])) {
is better than
if (is_array($this->config['config']['defaultGetVars.'])) {
in this case, because if you have something like this in your TS
config.defaultGetVars {
# tx_ttnews.year = 2004
}
defaultGetVars will be an empty array and
array_merge_recursive_overrule() will be executed without need.
besides this:
+1 by reading an testing
greets
rupert
Oliver Hader schrieb:
> Hi Steffen,
>
> Steffen Kamper schrieb:
>> Hi,
>>
>> just a reminder for a core dev
>
> +2070» » » //·merge·GET·with·defaultGetVars
> +2071» » if·(is_array($this->config['config']['defaultGetVars.']))·{
> +2072» » » $getVars·=·t3lib_div::_GET();
> +2073» » »
> $defaultGetVars·=·t3lib_div::removeDotsFromTS($this->config['config']['defaultGetVars.']);
> +2074» » »
> $newGetVars·=·t3lib_div::array_merge_recursive_overrule($defaultGetVars,·is_array($getVars)·?·$getVars·:·array());
> +2075» » » if·(count(array_diff($getVars,·$newGetVars)))·{
> +2076» » » » t3lib_div::_GETset($getVars);
> +2077» » » }» »
> +2078» » }
>
> Interesting that there are already two positive votes on reading.
>
> My remarks:
>
> 1) the patch sets the identical GET vars again that are alreay set - it
> uses $getVars instead of $newGetVars
>
> 2) The superglobal $_GET is always an array, even in CLI mode where no
> GET vars are available - the is_array() check is superflouos here
>
> 3) array_diff() returns the differences of values and only those that
> are present in the first argument (the original GET vars)
> 3a) we should use array_diff_assoc()
> 3b) we should search the difference in the bigger array thus using
> $newGetVars as first parameter
> 3c) array_diff_assoc will not recognize changes on nested keys, e.g
> &argument[key1]=1 and defaultGetVars.argument.key2=2
> 3d) we don't need the diff at all, since the merging already extends the
> original array and overrides keys recursively if they are defined in
> defaultGetVars
>
> I changed the mentioned things in my attached patch.
>
> +1 on reading and testing
>
> Again, I'd like to have another "+1 on reading and testing" from anyone.
> Thanks!
>
> olly
>
More information about the TYPO3-team-core
mailing list