It would be great to add support in a future version of Linkchecker to scan menu blocks (or scan the underlying menus) to find broken links. We have a use case where we are using the Linkchecker data tables to examine internal links and find orphaned pages, and it would be great to take into account menu links. It's very easy for menu links to point to nowhere or become broken links over time as a site ages.

Has this ever been discussed? Anyone else interested? Does anyone have a patch or some code to start on?

#2 linkchecker-scan-menu-links-1975110-2.patch538 bytescalebtr
PASSED: [[SimpleTest]]: [MySQL] 159 pass(es). View


calebtr’s picture

Issue summary: View changes

I can think of two use cases for this:

- external links in your menus!
- menu links to views with contextual filters that could return no results (you'd have to set the view to return a 404 in this instance however)

It seems doable and I am working on this from the "scan the underlying menus" approach. I'll share when I can.

calebtr’s picture

Status: Active » Needs review
538 bytes
PASSED: [[SimpleTest]]: [MySQL] 159 pass(es). View

I've set up a sandbox for a Linkchecker Menu sub-module, which extends Linkchecker to scan menus for links.

It is required to also patch Linkchecker, attached, so that hook_query_TAG_NAME_alter can be invoked. Without the patch, Linkchecker will remove menu links from the database as part of routine garbage collection.

Menu links are a little different from links in nodes, comments and custom blocks in that they aren't owned by a particular user. Broken menu links will only show on the main "broken links" page. That page does not check access for menu links, which I will work on next.

I also opted to not batch the adding/deleting of links when a single menu link is inserted in, updated in, or deleted from a menu.

I didn't do any Drush integration.

If the module maintainer is up for it, I can convert the sub-module into a patch for Linkchecker.