ZF-3472: Zend_Controller_Request_Abstract::setParams is not unsetting pre-existing values

Issue Type: Bug Created: 2008-06-17T18:47:23.000+0000 Last Updated: 2011-08-13T21:49:33.000+0000 Status: Resolved Fix version(s): - 1.11.11 (29/Sep/11)

Reporter: Cole Snodgrass (cole.snodgrass) Assignee: Pádraic Brady (padraic) Tags: - Zend_Controller

  • zf-crteam-padraic
  • zf-crteam-priority

Related issues: Attachments:


<pre class="highlight">
require_once 'Zend/Controller/Request/Simple.php';
$r = new Zend_Controller_Request_Simple();
$r->setParam('key', 'value');
        'key' => null

The preceding code should output:

<pre class="highlight">
array(0) {

but is actually outputting:

<pre class="highlight">
array(1) {
  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.

<pre class="highlight">
require_once 'Zend/Controller/Request/Simple.php';
$r = new Zend_Controller_Request_Simple();
$r->setParam('key', 'value');
$r->setParam('key', null);


Posted by Stefano Tamagnini (yoghi) on 2010-03-05T12:15:08.000+0000

REFERENCE ZF 1.10.1 try:

<pre class="highlight">

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 :

<pre class="highlight">
    public function getParam($key, $default = null)
        $keyName = (null !== ($alias = $this->getAlias($key))) ? $alias : $key;

        $paramSources = $this->getParamSources();
        if (isset($this->_params[$keyName])) {
            return $this->_params[$keyName];
        } elseif (in_array('_GET', $paramSources) && (isset($_GET[$keyName]))) {
            return $_GET[$keyName];
        } elseif (in_array('_POST', $paramSources) && (isset($_POST[$keyName]))) {
            return $_POST[$keyName];

        return $default;

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.