Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm getting a bunch of errors when I try to display a menu block on a forum page. I originally thought that this had to do with Advanced Forum, but I disabled that module and I'm still getting errors:
Notice: Undefined index: hidden in menu_block_tree_output() (line 611 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
Notice: Undefined index: has_children in menu_block_tree_output() (line 629 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
Notice: Undefined index: href in menu_block_tree_output() (line 643 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
Notice: Undefined index: href in menu_block_tree_output() (line 643 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
Notice: Undefined index: mlid in menu_block_tree_output() (line 647 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
Notice: Undefined index: title in menu_block_tree_output() (line 658 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
Notice: Undefined index: href in menu_block_tree_output() (line 659 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
Notice: Undefined index: mlid in menu_block_tree_output() (line 665 of /var/www/sites/oga2/featuretest/sites/all/modules/menu_block/menu_block.module).
This appears to be happening because $data['below'] contains some links that have only an in_active_trail variable and nothing else.
Comment | File | Size | Author |
---|---|---|---|
#12 | menu_block_1204064_menu_tree_add_active_path.patch | 657 bytes | MrHaroldA |
#7 | menu_block-1204064-2.patch | 668 bytes | pjcdawkins |
Comments
Comment #1
BartK CreditAttribution: BartK commentedNote that I'm not the only site this has happened to... A google search for the error has revealed a cached page with the same issue:
http://webcache.googleusercontent.com/search?q=cache:C3J3Gk4LoyQJ:www.nu...
Comment #2
BartK CreditAttribution: BartK commentedI've got a fix for this that gets rid of the error message.
In menu_block.module, in the function menu_tree_add_active_path, change:
if ($tree_with_trail[$key]['link']['in_active_trail']) {
to
if ($tree_with_trail[$key]['link']['in_active_trail'] && array_key_exists($key, $subtree_pointer)) {
(around line 423)
It looks like the menu_tree_page_data is returning active trail items that aren't actually in the menu, but the function as it stands is assuming that they are.
Comment #3
isaacfreeman CreditAttribution: isaacfreeman commentedI add this issue too, on many admin pages. BartK's fix has done the trick.
Comment #4
JustMagicMaria CreditAttribution: JustMagicMaria commentedSame. Note I changed the issue title since this isn't just on forums. BartK's fix worked for me too.
Comment #5
TimelessDomain CreditAttribution: TimelessDomain commented#2 works.
Comment #6
jras CreditAttribution: jras commented#2 worked for me as well.
Comment #7
pjcdawkins CreditAttribution: pjcdawkins commentedHere's a patch version of BartK's fix in #2.
Comment #8
acrollet CreditAttribution: acrollet commentedPatch in #7 works for me, leaving as RTBC.
Comment #9
tjg CreditAttribution: tjg commentedAny chance this patch will be included in menu_block soon?
Comment #10
tim.plunkettThe
array_key_exists()
portion should be replaced withisset($subtree_pointer[$key])
, see http://php.net/array_key_exists#example-4540Comment #11
Rory CreditAttribution: Rory commented@tim.plunkett - I couldn't find the example you were specifically linking to. But I thought this might be it: http://php.net/manual/en/function.array-key-exists.php#87491
Comment #12
MrHaroldA CreditAttribution: MrHaroldA commentedRerolled the patch with isset() like tim.plunkett suggested.
This patch fixes these notices:
Comment #13
MrHaroldA CreditAttribution: MrHaroldA commentedForgot to set status to 'needs review'...
Comment #14
pjcdawkins CreditAttribution: pjcdawkins commented#12 works for me
Comment #15
lstoetzel CreditAttribution: lstoetzel commented#12 works for me
Comment #16
gmclelland CreditAttribution: gmclelland commentedPatch in #12 worked for me.
Comment #17
pjcdawkins CreditAttribution: pjcdawkins commentedStill works for me! Marking RTBC.
Note that this issue is for the -2.x branch while there's also a -3.x. It looks like it's fairly trivial to produce a similar patch for 3.x, but let's keep this thread simple until the maintainer responds.
Comment #18
gmclelland CreditAttribution: gmclelland commentedSorry, I spoke to soon. The error I see is bit different and doesn't apply to this issue.
Comment #19
ayalon CreditAttribution: ayalon commentedTested and working
Please commit it.
Comment #20
Mirroar CreditAttribution: Mirroar commentedConfirming that it works for me as well. Thanks for the patch!
Comment #21
jci CreditAttribution: jci commentedWorks for me - thanks! Please commit it.
Comment #22
Cauliflower CreditAttribution: Cauliflower commentedPatch in #12 works as expected.
Comment #23
JohnAlbinFixed. http://drupalcode.org/project/menu_block.git/commitdiff/c7c644b