After upgrading to Drupal 7.12, the Menu Position module doesn't seem to give a correct active trail to affected nodes, even if 'Structure/Menu position rules/Settings/When a position rule matches' is set to 'Insert the current page's title into the menu tree'. menu_get_active_trail() returns a trail containing just the front page.

I've tested with version 7.x-1.0 and the latest 7.x-2.x-dev cloned from Git.

The Menu Block module had to be patched for Drupal 7.12: maybe this is related? http://drupal.org/node/1425342

CommentFileSizeAuthor
#2 1426482-fix-default-override.patch830 bytescraigjones

Comments

C. Lee’s picture

I have the same issue. The following issues seem relevant:

http://drupal.org/node/942782 [core] Custom menus never receive an active trail
http://drupal.org/node/1425342 [menu_block] Drupal core upgrade from 7.10 to 7.12 causes menu block to fail
http://drupal.org/node/1351678 [i18n] Follow menu_link_get_preferred active trail handling for custom menus

craigjones’s picture

StatusFileSize
new830 bytes

I've encountered this same issue today as well, and have done a bit of digging.

It appears that menu_position_activate_rule() grabs the cache created by menu_link_get_preferred() (via drupal_static() ) and then attempts to rewrite the entries. However, the internal structure of the cache in menu_link_get_preferred() has been altered between versions, so the keys in the cache are different thus the rewriting creates an invalid array, that when menu_get_active_trail() is later called, returns just the top-level entry as a result.

Attached is a patch against 7.x-1.0

C. Lee’s picture

Applied the patch in #2. Now the breadcrumbs are showing correctly, yet my menu block is still not appearing. I cannot confirm whether the bug is in Menu position, Menu block, or the Internationalization.

tomcashman’s picture

#2 works for me, patched against Menu Position 7.x-1.0 and running alongside Menu Block 7.x-2.3. Thanks!

hyperglide’s picture

#2 works for me -- fixes breadcrumb.

C. Lee’s picture

Status: Reviewed & tested by the community » Active

Now #2 works for me too; it was setting "Menu" as <the menu selected by the page> at the block configuration page that caused my problem.

gaele’s picture

Status: Active » Reviewed & tested by the community
tekket’s picture

Status: Active » Reviewed & tested by the community

#2 fixed my breadcrumbs. Great job craigjones.

dave reid’s picture

Yep agreed this is RTBC.

johnalbin’s picture

Status: Reviewed & tested by the community » Fixed
gsquirrel’s picture

Any chance this patch could be applied to the 7.x-1.0 version? Applying it manually sorted out the issues i was having after the core upgrade.

mgifford’s picture

@craigjones - can help explain why your patch works?

I'm not actually using Menu Permissions, but trying to figure out how you fixed this issue with the active trail.

The patch is simple, but I'm not sure what [MENU_PREFERRED_LINK] relates to.

@@ -324,7 +324,7 @@ function menu_position_activate_rule($rule, $context, $set_breadcrumb) {
     // Manually set the preferred link for this path so that
     // menu_get_active_trail() returns the proper trail.
     $preferred_links = &drupal_static('menu_link_get_preferred');
-    $preferred_links[$_GET['q']] = menu_link_get_preferred($menu_item['link_path']);
+    $preferred_links[$_GET['q']][MENU_PREFERRED_LINK] = menu_link_get_preferred($menu_item['link_path']);
 
     // Remove the menu position router from the end of the trail.
     $active_trail = menu_set_active_trail();

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.