ZF-3472: Zend_Controller_Request_Abstract::setParams is not unsetting pre-existing values
Description
require_once 'Zend/Controller/Request/Simple.php';
$r = new Zend_Controller_Request_Simple();
$r->setParam('key', 'value');
$r->setParams(
array(
'key' => null
)
);
var_dump($r->getParams());
The preceding code should output:
array(0) {
}
but is actually outputting:
array(1) {
["key"]=>
string(5) "value"
}
{{getParams()}} should be returning an empty array because {{setParams}} is defining {{key}} to be {{null}} and should therefore be calling {{unset}} on that value.
If I modified the code to the following, then everything works as expected.
<?php
require_once 'Zend/Controller/Request/Simple.php';
$r = new Zend_Controller_Request_Simple();
$r->setParam('key', 'value');
$r->setParam('key', null);
var_dump($r->getParams())
Comments
Posted by Stefano Tamagnini (yoghi) on 2010-03-05T12:15:08.000+0000
REFERENCE ZF 1.10.1 try:
correct unset variable into Zend_Controller_Request_Http, because into Zend_Controller_Request_Http on getParam(...) it try to find variable name into $_GET & $_POST :
Posted by Ralph Schindler (ralph) on 2011-02-17T15:37:28.000+0000
Matthew, any notes on this?
Posted by Pádraic Brady (padraic) on 2011-08-13T21:49:33.000+0000
Fixed r24372. No apparent test breakages. Null check in method doesn't verify against original parameter so it missed the array addition issue.