I manually added the "user" path as a shortcut with a plain Drupal 7.15 site and got this error:

Notice: Undefined index: module in user_menu_link_alter() (line 1860 of /var/aegir/platforms/d715/modules/user/user.module).

I think the shortcut module should provide a "module" index for the links it adds. This is what the attached patch does.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Title: Shortcut warning when manually adding a "user" path » Undefined index warning in user_menu_link_alter() when manually adding a "user" path as a shortcut
Component: shortcut.module » user.module
Status: Needs review » Needs work
Issue tags: +Needs backport to D7

I think this is a bug in the user module; menu_link_save() does not specify that 'module' is required, so its existence shouldn't be assumed in the alter hook.

Also, the code comments in shortcut_set_save() explain why we don't want to set 'shortcut' as the module here (but rather rely on the default).

David_Rothstein’s picture

For Drupal 8, a better fix might be to consider moving the drupal_alter() call in menu_link_save() a little later (after the defaults have been added to the menu item); that way, the alter hook is actually working with a complete menu link record. If so, this patch could be for the menu system rather than the user module.

However, that change might not necessarily be backportable to Drupal 7.

iamdan’s picture

I'm not sure what to do with this. I'm getting the error as well when customizing the shortcut bar. 7.22. I've added a few shortcuts and they seem to work. Do I need to be concerned about this re the site. Or is it just a problem when adding these links? Or should I use the patch above? Thanks for your patience with the question.

GuyPaddock’s picture

Version: 8.0.x-dev » 7.x-dev
Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.03 KB

I wholeheartedly agree with #1 -- there is no expectation that module must be provided in the link.

Attached is a patch that checks for the key with isset(). Another approach would be to move the drupal_alter() call in menu_link_save() after the application of default values, but I feel like that change would be much more breaking.

I know the backport policy, but I'm bumping this to 7.x to get Testbot's attention.

Status: Needs review » Needs work
GuyPaddock’s picture

Status: Needs work » Needs review
FileSize
1.03 KB

Go home, Guy... you're drunk.

Re-roll with correct syntax.

GuyPaddock’s picture

Version: 7.x-dev » 8.0.x-dev
Status: Needs review » Active

Patch works for D7.

Setting to Active for D8 so we can get a D8 patch.

subhojit777’s picture

Version: 8.0.x-dev » 7.x-dev

Not able to reproduce the problem in latest codebase of Drupal 8

Sivaji_Ganesh_Jojodae’s picture

Status: Active » Reviewed & tested by the community

I confirm this is not an issue for Drupal 8.

Patch #6 does the needful for Drupal 7.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Yeah, it looks like this code is now long gone from Drupal 8. And a test for something this minor is probably not worth it.

Committed to 7.x - thanks!

  • David_Rothstein committed 69b1ff8 on 7.x
    Issue #1719280 by GuyPaddock, Robin Millette: Undefined index warning in...

Status: Fixed » Closed (fixed)

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