Issues

ZF-9038: Last empty param is missing in params list

Issue Type: Bug Created: 2010-02-01T07:21:40.000+0000 Last Updated: 2012-11-20T21:37:41.000+0000 Status: Open Fix version(s): Reporter: Lukasz Witczak (squid) Assignee: None Tags: - Zend_Controller

Related issues: Attachments:

Description

If last param in uri is empty - http://example.com/controller/action/… getParams() or getParam() method from request class doesn't return this param (param2) and when the uri is like this: http://example.com/controller/action/… param1 is declared but empty. I've noticed it in ZF 1.9.7 but this bug also has influence on 1.10 and maybe other versions.

This problem has a source in Zend_Controller_Router_Route_Module::match() method. Match() body trims a path to clear trailing and ending self::URI_DELIMITER:

<pre class="highlight">
and when the uri is like this: <a href="http://example.com/controller/action/param1/some_value/param2//">http://example.com/controller/action/…</a> the result is: controller/action/param1/some_value/param2
Then "for" loop determines if some value exist after param2 and because of trim it doesn't exist so the null value is assigned to param2
Unfortunately Zend_Controller_Request_Abstract::setParam() use unset for those params (whith null values):

if ((null === $value) && isset($this->_params[$key])) { unset($this->_params[$key]); } elseif (null !== $value) { $this->_params[$key] = $value; }

<pre class="highlight">

my suggestion is to replace code from Zend_Controller_Router_Route_Module::match():

to this one:


in this way the last empty param should have the same value like the empty param in the middle of path.

 

 

### Comments

Posted by Jan Pieper (jpieper) on 2010-11-15T22:58:54.000+0000

Fixed formatting.

 

 

Posted by Jan Pieper (jpieper) on 2010-11-16T13:44:47.000+0000

I wasn't able to find any unittest that will break after this change but i don't know whether this will break backward compatibility because isset() etc. will return TRUE instead of FALSE.

 

 

Have you found an issue?

See the Overview section for more details.

Copyright

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

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

Contacts