ZF-11545: Zend_Navigation_Page_Mvc::isActive returns false unless variable route parts match defaults

Description

The fix for issue ZF-11359 broke my application. I have a route which accepts several parameters for sorting a list of items, I want to be able to generate a breadcrumb for this page, but because of the update, the page is only marked as active when using the default sorting parameters.


resources.router.routes.property_list.route                   = "/admin/property/:sort_col/:sort_ord/:page/:items_per_page"
resources.router.routes.property_list.defaults.controller     = "property"
resources.router.routes.property_list.defaults.action         = "list"
resources.router.routes.property_list.defaults.sort_col       = "address"
resources.router.routes.property_list.defaults.sort_ord       = "asc"
resources.router.routes.property_list.defaults.page           = 1
resources.router.routes.property_list.defaults.items_per_page = 20
resources.router.routes.property_list.reqs.page               = "\d+"
resources.router.routes.property_list.reqs.items_per_page     = "\d+"

resources.navigation.pages.admin.pages.sections.pages.property.label      = "Properties"
resources.navigation.pages.admin.pages.sections.pages.property.id         = "admin_property"
resources.navigation.pages.admin.pages.sections.pages.property.route      = "property_list"
resources.navigation.pages.admin.pages.sections.pages.property.module     = "default"
resources.navigation.pages.admin.pages.sections.pages.property.controller = "property"
resources.navigation.pages.admin.pages.sections.pages.property.action     = "list"

Defaults compared in old code:


array (
  'sort_col' => 'address',
  'sort_ord' => 'desc',
  'page' => '1',
  'controller' => 'property',
  'action' => 'list',
  'items_per_page' => '20',
  'module' => 'default',
)

array (
  'module' => 'default',
  'controller' => 'property',
  'action' => 'list',
)

isActive returns true because only the module, controller, action parts of page defaults are checked against route.

Defaults compared in new code:


array (
  'sort_col' => 'address',
  'sort_ord' => 'desc',
  'page' => '1',
  'controller' => 'property',
  'action' => 'list',
  'items_per_page' => '20',
  'module' => 'default',
)

array (
  'controller' => 'property',
  'action' => 'list',
  'sort_col' => 'address',
  'sort_ord' => 'asc',
  'page' => '1',
  'items_per_page' => '20',
  'module' => 'default',
)

isActive return false because route defaults are checked against current request defaults.

Comments

Problem still occurs in 1.11.9.

Problem still occurs in 1.11.10

Ugly workaround for our breadcrumbs is to reset to defaults before displaying the breadcrumbs and restoring their custom values after.

This needs to be bumped up in priority. It's a pretty nasty bug.

I'm not very sure but with this it seems work fine:


if ($this->_route) {
    $route = $front->getRouter()->getRoute($this->_route);
    if (method_exists($route, 'getDefaults')) {
        $myParams = array_merge(
            $route->getDefaults(), $myParams, $reqParams
        );
    }
}