Updated: Comment #N

Problem/Motivation

menu.inc still contains menu_link-specific code.

Proposed resolution

Move it to menu_link.module

Remaining tasks

Decide if more of the menu tree functions should move as well.

User interface changes

N/A

API changes

menu_load_links() and menu_delete_links() were renamed to menu_link_load_links_by_menu() and menu_link_delete_links_by_menu()

Original report by @pwolanin

Follow-up from #2047633: Move definition of menu links to hook_menu_link_defaults(), decouple key name from path, and make 'parent' explicit.

The code in menu.inc already has a check as to whether the menu_link module is enabled. It would be logically better to simply move all the code for finding/saving/resetting default menu links to this module and out of menu.inc.

CommentFileSizeAuthor
#4 menu_link-2178697-4.patch23.08 KBtim.plunkett

Comments

pwolanin’s picture

xjm’s picture

I'm assuming this would involve API changes as the functions were renamed to the menu_link namespace? Can we document the list of any API changes here in the summary and make sure to get a maintainer's +1? Presumably it should be pretty straightforward. Thanks!

tim.plunkett’s picture

Sadly enough, these are in menu.inc still:

menu_link_get_preferred()
menu_link_get_defaults()
menu_link_rebuild_defaults()

So they don't need renaming :)

Not sure what else we'd want to move.

tim.plunkett’s picture

Issue summary: View changes
StatusFileSize
new23.08 KB

Okay, since the menu_router patch went in, I took a look at this.

I moved the 3 functions I mentioned already, which doesn't actually affect anything since menu_link is required.

The other two that were specifically about menu links were menu_load_links() and menu_delete_links(), which I renamed to menu_link_load_links_by_menu() and menu_link_delete_links_by_menu(), since that's what they do.

tim.plunkett’s picture

Status: Active » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Let's not get crazy with more changes, given that this just would need more time.

dawehner’s picture

#2207893: Convert menu tree building to a service. works on moving many other bits to menu_link.

xjm’s picture

Created draft change record:
https://drupal.org/node/2208411

I also checked and found no references to menu_load_links() or menu_delete_links() in existing change records.

catch’s picture

Status: Reviewed & tested by the community » Needs work

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21EventSubs...

This calls menu_link_rebuild_defaults() and others. It's slightly worse calling a function in module than one in /includes.

Feels like menu_link module should have its own subscriber that calls its own methods.

pwolanin’s picture

Status: Needs work » Needs review

mgifford queued 4: menu_link-2178697-4.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 4: menu_link-2178697-4.patch, failed testing.

pwolanin’s picture

Status: Needs work » Closed (won't fix)

I think this is outdated or already fixed by the menu link API changes