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 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.
Comment | File | Size | Author |
---|---|---|---|
#6 | drupal-user_menu_link_alter_expects_module-1719280-6-7.x.patch | 1.03 KB | GuyPaddock |
shortcut-missing-module-index-user-fix.patch | 751 bytes | Robin Millette | |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedI 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).
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedFor 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.
Comment #3
iamdan CreditAttribution: iamdan commentedI'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.
Comment #4
GuyPaddock CreditAttribution: GuyPaddock at RedBottle Design, LLC for House at Work commentedI 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 thedrupal_alter()
call inmenu_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.
Comment #6
GuyPaddock CreditAttribution: GuyPaddock at RedBottle Design, LLC for House at Work commentedGo home, Guy... you're drunk.
Re-roll with correct syntax.
Comment #7
GuyPaddock CreditAttribution: GuyPaddock at RedBottle Design, LLC for House at Work commentedPatch works for D7.
Setting to Active for D8 so we can get a D8 patch.
Comment #8
subhojit777Not able to reproduce the problem in latest codebase of Drupal 8
Comment #9
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedI confirm this is not an issue for Drupal 8.
Patch #6 does the needful for Drupal 7.
Comment #10
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedYeah, 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!