Issues

ZF-7928: Rest route doesn't work in chains in some cases

Issue Type: Bug Created: 2009-09-22T20:06:41.000+0000 Last Updated: 2009-11-19T16:37:12.000+0000 Status: Resolved Fix version(s): - 1.9.6 (24/Nov/09)

Reporter: Vladimir Razuvaev (vladar) Assignee: Luke Crouch (lcrouch) Tags: - Zend_Rest_Route

Related issues: Attachments:

Description

Zend_Rest_Route doesn't work in chains with Zend_Controller_Router_Route.

Here is a simple test case:

<pre class="literal"> 
$route = new Zend_Controller_Router_Route('api');
$router->addRoute("api", $route->chain(new Zend_Rest_Route($front)));

The problem is that Zend_Rest_Route doesn't set matched path in it's "match" method (which is required for chaining to work). As I think it should behave similar to Zend_Controller_Router_Route_Module, which uses following code:

<pre class="literal"> 
public function match($path, $partial = false) 
{
    // skipping method body

    if ($partial) {
        $this->setMatchedPath($matchedPath);
    }

    // skipping
}

Comments

Posted by Luke Crouch (lcrouch) on 2009-09-29T14:39:57.000+0000

Can you help me by expanding the test case code? How is $router defined?

thanks, -L

Posted by Vladimir Razuvaev (vladar) on 2009-09-29T23:04:42.000+0000

Here is a full test case code:

[code] $front = Zend_Controller_Front::getInstance(); // default ZF router: $router = $front->getRouter(); $router->removeDefaultRoutes();

$route = new Zend_Controller_Router_Route('api'); $router->addRoute("api", $route->chain(new Zend_Rest_Route($front))); [/code]

When trying to navigate to /api/controller/id exception is thrown: Zend\Controller\Router\Rewrite.php, line 341: Current route is not defined

Currently, I have subclassed Zend_Rest_Route with following code to make it work in chains:

[code] class RestRoute extends Zend_Rest_Route { public function match($request, $partial = false) { $result = parent::match($request); if($partial && $result) { $this->setMatchedPath($request->getPathInfo()); } return $result; } }

[/code]

This is trivially copy-paste from Zend_Controller_Router_Route_Module

Posted by Luke Crouch (lcrouch) on 2009-10-10T11:54:30.000+0000

Added partial logic to Zend_Rest_Route::match to support using Zend_Rest_Route in route chains.

Posted by Bradley Holt (bradley.holt) on 2009-11-15T06:43:40.000+0000

This issue is not fixed in 1.9.4. The code attached to this issue is not present in 1.9.4 or 1.9.5. It appears to be present in trunk but not in the release-1.9 branch. This code should either be merged into the release-1.9 branch or this issue should have its Fix Version set to 1.10.

Posted by Matthew Weier O'Phinney (matthew) on 2009-11-19T16:37:12.000+0000

Patch merged to 1.9 release branch; will release with 1.9.6.

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