Issues

ZF-11359: Zend_Navigation_Page_Mvc::isActive is not route aware

Description

Zend_Navigation_Page_Mvc::isActive is not route aware, and will return false when the page is active, but uses a route.

Comments

Patch: http://pastie.org/1886576

Note that getDefaults is not a part of Zend_Controller_Router_Route_Interface, so the method_exists check is necessary. Also, Zend_Controller_Router_Route_Chain does not implement getDefaults, but I think that should be possible.

Add patches from Môshe van der Sterre

Kai, I see that you assigned this issue to yourself. Does that mean you're planninng on committing it? If not, please assign it to me so I can commit the patches.

Hi Dolf, Feel free to commit. It does not matter who does it! :-)

Anyone to commit ? Seems is affecting me as well...

Hey Christian,

See also this tweet: https://twitter.com//…

tldr; will do so this weekend.

Thanks Freeaqingme, take your time...

As mentioned above this patch does not work for chained routes. I patched this issue by comparing the assembled URLs of the current route and the route used by Zend_Navigation_Page_Mvc:


if ($this->_route) {
    /*
     * Patch ZF-11359
     * For Zend_Controller_Router_Route_Chain
     */
    try {
        if ($front->getRouter()->getCurrentRouteName() === $this->_route && $this->getHref() === self::$_urlHelper->url(array(), null, false, false)) {
            $this->_active = true;
            return true;
        }
    } catch (Zend_Controller_Router_Exception $e) {
    }


    /**
     * Patch ZF-11359
     * ZF-11359_Fix_Patch.diff
     */
    $route = $front->getRouter()->getRoute($this->_route);
    if(method_exists($route, 'getDefaults')) {
        $myParams = array_merge($route->getDefaults(), $myParams);
    }
}

I guess would worth to check if the route is chained and only use the patch for a chained route.

This makes sense to avoid too much assemble processing....

This issue was assigned to me because it was about merely applying a patch. Apparently the patch does not meet the quality standards ZF aims at. I am reassigning the issue, and assume it will not be resolved before ZF2.

Of course, this is not the case if a patch shows up that also supports chained links in a performant manner. Thank you for making ZF better!

Freeaqingme, i suggest to at least patch with the initial solution, which works for non-chained routes. Otherwise it makes sense to fully remove the isActive related features...

I mean, there is a solution which is fixing for at least many of the cases so it makes sense to either apply the patch or remove the features (which i don't think is a choice would lead to BC break).

Applied original patch(es). They should be released with version 1.11.8.

Committed in r24118 merged with release 1.11 branch in r24119. For the chained route stuff, please create a new issue.

Thank you for making ZF better.

Thanks Freeaqingme.

I raised a new issue for the chained routes case:

http://framework.zend.com/issues/browse/ZF-11442