Problem/Motivation

panels_breadcrumbs calls hook_menu_breadcrumb_alter() like this:

$breadcrumb_info_end = end($breadcrumbs_info);
drupal_alter('menu_breadcrumb', $breadcrumbs_info, $breadcrumb_info_end);

It's passing the last item in the breadcrumbs array to the 2nd argument of hook_menu_breadcrumb_alter().

However, core always passes the menu item of the current page in that argument!

If you look at the API documentation for this alter hook, it says:

Parameters

$active_trail: An array containing breadcrumb links for the current page.

$item: The menu router item of the current page.

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

This is confirmed by looking at the code for menu_get_active_breadcrumb() in 'includes/menu.inc':

https://git.drupalcode.org/project/drupal/-/blob/7.x/includes/menu.inc#L...

Unfortunately, the way 'panels_breadcrumbs' is calling hook_menu_breadcrumb_alter() could mess up some contrib modules that are expecting that 2nd argument to be the menu item for the current page like when core calls it. I personally encountered this with the Rules Link module.

Steps to reproduce

n/a

Proposed resolution

Pass the menu item for the current page as the 2nd argument! Patch incoming :-)

Remaining tasks

  1. Write patch
  2. Review
  3. Merge!

User interface changes

None.

API changes

None in panels_breadcrumb, but other module will a receive different value for the 2nd argument of hook_menu_breadcrumb_alter(), but this value will be consistent with the way core calls that hook.

Data model changes

None.

Comments

dsnopek created an issue. See original summary.

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new673 bytes

Here's a patch to fix!

cboyden’s picture

Thanks for the patch @dsnopek. It applies to the dev branch, but that branch has a bunch of commits that are not yet released, so it doesn't apply to release 2.4 due to differences in line numbers. Here's an additional patch that should apply to release 2.4.

  • dsnopek committed b6f57cf on 7.x-2.x
    Issue #3256813 by dsnopek, cboyden: Call to hook_menu_breadcrumb_alter...
dsnopek’s picture

Status: Needs review » Fixed

Merged!

Status: Fixed » Closed (fixed)

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