Project

General

Profile

Actions

Bug #17296

closed

piVars does not support arrays

Added by Christian Boltz almost 17 years ago. Updated almost 16 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Communication
Target version:
-
Start date:
2007-05-11
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I just learned the hard way that piVars does not support arrays.

Create a frontend plugin with a <select multiple> field, add some options and select some of them. Then submit the form.

<form>
<select name="tx_foobar][select][]" size="5" multiple>
<option value="1">option 1</option><option value="2">option 2</option><option value="3" selected>option 3</option>
</select>
<input name="save" type="submit" value="save">
</form>

Expected result:
piVars['select'] is an array which contains the selected items

Actual result:
piVars['select'] contains the string "array" :-(

Unfortunately there is no other way to handle <select multiple> than using an array AFAIK.

(issue imported from #M5604)

Actions #1

Updated by Ingo Renner almost 17 years ago

please provide more detailed information or I'm going to close your report otherwise

Actions #2

Updated by Franz Holzinger almost 17 years ago

You can only enter normal parameters for an extension.
E.g.
http://mytypo3domain.com/index.php?id=32&tx_ttextensionname_pi1[param1]=1&tx_ttextensionname_pi1[param2]=2&tx_ttextensionname_pi1[param3]=3

So you have to repeat the rather long extension array for each extension parameter.

It would be shorter to have:

http://mytypo3domain.com/index.php?id=32&tx_ttextensionname_pi1='param1=1&param2=2&param3=3';
This is a proposal in pseudo URL, it must be encoded of course and could be done in better ways. However it would make the URL line smaller and easier to read.
The job to put this into piVars should be done by the tslib_pibase classe.

The relevant code is here:

tslib_pibase:
function tslib_pibase() {
// Setting piVars:
if ($this->prefixId) {
$this->piVars = t3lib_div::GParrayMerged($this->prefixId);
----------------
/**
  • Returns the GET/POST global arrays merged with POST taking precedence.
  • Usage: 1 *
  • @param string Key (variable name) from GET or POST vars
  • @return array Returns the GET vars merged recursively onto the POST vars.
  • @ignore
  • @deprecated
    */
    function GParrayMerged($var) {
    $postA = is_array($_POST[$var]) ? $_POST[$var] : array();
    $getA = is_array($_GET[$var]) ? $_GET[$var] : array();
    $mergedA = t3lib_div::array_merge_recursive_overrule($getA,$postA);
    t3lib_div::stripSlashesOnArray($mergedA);
    return $mergedA;
    }
Actions #3

Updated by Christian Boltz almost 17 years ago

Argh
After creating a small demo extension I couldn't reproduce the problem. I then noticed that the extension where I found the problem mangled piVars via

if ($this->piVars) {
foreach ($this->piVars as $key => $value)
$this->piVars[$key] = htmlspecialchars(stripslashes($value));
}

and stripslashes destroys the array and "converts" it to the string "Array" :-( (which is documented in the PHP documentation, so it isn't a PHP bug)

Sorry that I didn't notice this mangling earlier. Please close this bug as invalid.

(and: Franz, if you want a better URL parameter scheme, please open a new feature request for it.)

Actions #4

Updated by Oliver Hader almost 17 years ago

As requested by the reporter, this issue is closed.

Actions

Also available in: Atom PDF