Issues

ZF-6299: Zend_Controller_Router_Route_Static not work properly with empty _route

Issue Type: Bug Created: 2009-04-15T02:55:03.000+0000 Last Updated: 2010-10-21T09:12:50.000+0000 Status: Resolved Fix version(s): - 1.11.0 (02/Nov/10)

Reporter: Eugene Myazin (meniam) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller

Related issues: - ZF-7848

Attachments:

Description

Zend_Controller_Router_Route_Static::match

public function match($path)
{
    if ($this->isPartial()) {
        if (substr($path, 0, strlen($this->_route)) === $this->_route) {
            $this->setMatchedPath($this->_route);
            return $this->_defaults;
        }

} else {

When $this->_route is empty, construction substr($path, 0, strlen($this->_route)) return "bool(false)" and condition If is not fullfilled

Comments

Posted by Matthew Weier O'Phinney (matthew) on 2010-10-20T09:42:17.000+0000

Can you provide an example of when this is a problem, exactly? I'm having trouble finding a case where this would not actually be the correct and/or expected behavior.

Posted by Eugene Myazin (meniam) on 2010-10-20T12:07:18.000+0000

When default router disabled and path '/' should point to the non default IndexController::indexAction following occurs:

I add route:

$router->addRoute( 'index', new Zend_Controller_Router_Route_Static('/', array('controller' => 'user', 'action' => 'info')) );

Zend_Controller_Router_Route_Static::_construct do:

public function __construct($route, $defaults = array()) { $this->_route = trim($route, '/'); $this->_defaults = (array) $defaults;

}

Afther that we have empty string in $this->_route

Then in match

if (substr($path, 0, strlen($this->_route)) === $this->_route) {

It's wrong condition, mistake in "==="

Other example illustrate the problem:

public function match($path, $partial = false) { if ($partial) { --> // if (substr($path, 0, strlen($this->_route)) === $this->_route) { if ((empty($path) && empty($this->_route)) || (substr($path, 0, strlen($this->_route)) === $this->_route) ) { $this->setMatchedPath($this->_route); return $this->_defaults; } Posted by Matthew Weier O'Phinney (matthew) on 2010-10-21T09:12:50.000+0000 Yeah -- removed that from trunk and 1.11 release branch now. That was the original clause; the new clause is what solves the issue.

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