Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Fix for unmatched routes in navigation #4530

wants to merge 2 commits into from

2 participants


Zf 2.2 changed the navigation behaviour for the segment route from 2.1.5 it needs the route match to keep the old behavior only on error (404) pages the route is not matched and will throw and error on the getParams method as it is not an object.


Please add a unit test, so we don't have another regression in the future.


@weierophinney I have added a test, but am not sure if the route match object is required? Maybe it goes somewhere else wrong if an error event is triggered? The extra check in the if statement seems to work for me, but not sure what else can go wrong here :)


@Mech7 test looks good! The big question: does it fail prior to the fix? And it does. :) Merging!

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4530'
Close #4530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  library/Zend/Navigation/Page/Mvc.php
@@ -197,7 +197,7 @@ public function getHref()
- if ($this->useRouteMatch()) {
+ if ($this->useRouteMatch() && $this->getRouteMatch()) {
$rmParams = $this->getRouteMatch()->getParams();
if (isset($rmParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
13 tests/ZendTest/Navigation/Page/MvcTest.php
@@ -68,6 +68,19 @@ public function testHrefGeneratedByRouterRequiresNoRoute()
$this->assertEquals('/news/view', $page->getHref());
+ public function testHrefRouteMatchEnabledWithoutRouteMatchObject()
+ {
+ $page = new Page\Mvc(array(
+ 'label' => 'foo',
+ 'route' => 'test/route',
+ 'use_route_match' => true
+ ));
+ $router = $this->getMock('\Zend\Mvc\Router\Http\TreeRouteStack');
+ $router->expects($this->once())->method('assemble')->will($this->returnValue('/test/route'));
+ $page->setRouter($router);
+ $this->assertEquals('/test/route', $page->getHref());
+ }
public function testHrefGeneratedIsRouteAware()
$page = new Page\Mvc(array(
Something went wrong with that request. Please try again.