I noticed some invalid code in path.inc, drupal_valid_path() while stepping through.

$form_item doesn't exist, and the keys being referenced don't exist in the menu_router table. (link_path, link_title)

$item['link_path'] and $item['link_title'] are being used in _menu_link_translate() and _menu_item_localize(), so I fixed the var and array key names to populate those.

Relative code in core/includes/path.inc

if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
  $item['link_path']  = $form_item['link_path'];
  $item['link_title'] = $form_item['link_title'];
  $item['external']   = FALSE;
  $item['options'] = '';
  _menu_link_translate($item);
}

Cleaned up version.

if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
  $item['link_path']  = $item['path'];
  $item['link_title'] = $item['title'];
  $item['external']   = FALSE;
  $item['options'] = '';
  _menu_link_translate($item);
}

That said, I'm not sure how menu link items are supposed to support wildcards. You can trigger this code by adding a menu item with "/%" somewhere in the path.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Priority: Major » Normal
Status: Needs review » Reviewed & tested by the community

Nice find!
Thankfully we're actively working to remove the {menu_router} table, so this is not a major bug.
Also, I don't think we need tests for that case either, same reason.

So, RTBC!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Hm. Okie doke then!

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

additional info

brad.bulger’s picture

Version: 8.x-dev » 7.x-dev
Issue summary: View changes
Status: Closed (fixed) » Needs review
Issue tags: +Needs backport to 7.x
FileSize
775 bytes

Same issue and fix applies in 7.x

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

ChaseOnTheWeb’s picture

Issue tags: +Quick fix

#4 fixes an issue I had with trying to use a to_arg function within a custom menu item. Hope this can be committed soon!

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Hm... I committed this because it went into Drupal 8 already (and it can't be any more broken after this patch than it was before it), but this is kind of duplicate of #876580: drupal_valid_path fails for dynamic paths (e.g. user/% cannot be added to menus) (for both Drupal 7 and Drupal 8) which has tests and a lot more discussion.

Status: Fixed » Closed (fixed)

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