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


Zend_Rest_Route doesn't work in chains with Zend_Controller_Router_Route.

Here is a simple test case:

$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:

public function match($path, $partial = false) 
    // skipping method body

    if ($partial) {

    // skipping


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

thanks, -L

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; } }


This is trivially copy-paste from Zend_Controller_Router_Route_Module

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

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.

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