ZF-12414: Zend_Navigation_Page_Mvc marks routes with an empty parameter always active (with easy fix)

Issue Type: Patch Created: 2012-09-10T23:24:49.000+0000 Last Updated: 2013-01-11T08:19:36.000+0000 Status: Resolved Fix version(s): - 1.12.2 (25/Feb/13)

Reporter: exceptione (exceptione) Assignee: Frank Brückner (frosch) Tags: - Zend_Navigation

  • FixForZF1.12.1

Related issues: Attachments:


h2. Problem

I have a setup with multiple navigation pages, each haveing a different value for the slug parameter. Home has an empty slug.

If browse to any page with non-empty slug like news the news menu item will be active. Thats good. Whats wrong is that the home menu item will be marked as active as well, but that has an empty slug.

h3. Example code

<pre class="highlight"> = Zend_Controller_Router_Route_Regex = "((?!(admin|page)).*)" = "page" = "index" = "index" = "slug" = "%s"

resources.navigation.pages.home.label            = 'About'
resources.navigation.pages.home.params.slug      = ''
resources.navigation.pages.home.encodeUrl        = true
resources.navigation.pages.home.route            = 'page'            = 'News'      = 'news'        = false            = 'page'

resources.navigation.pages.products.label        = 'Products'
resources.navigation.pages.products.params.slug  = 'products'
resources.navigation.pages.products.encodeUrl    = false
resources.navigation.pages.products.route        = 'page'

h2. Solution

Zend_Navigation_Page_Mvc::isActive() contains this code

<pre class="highlight"> 
foreach($myParams as $key => $value) {
   if($value == null) {

Imho the fault is in {color:red} == {color}, it should be strictly equal {color:green} === {color}


Posted by Frank Brückner (frosch) on 2012-09-11T19:35:49.000+0000

I will add a patch with unit tests.

Posted by Frank Brückner (frosch) on 2013-01-11T08:19:36.000+0000

Fixed on trunk (25212) and release-1.12 (25213)

Have you found an issue?

See the Overview section for more details.


© 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.