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.
Comment | File | Size | Author |
---|---|---|---|
#4 | drupal_valid_path_cleanup-7-2106129-4.patch | 775 bytes | brad.bulger |
drupal_valid_path_cleanup.patch | 795 bytes | mmilano | |
Comments
Comment #1
tim.plunkettNice 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!
Comment #2
webchickHm. Okie doke then!
Committed and pushed to 8.x. Thanks!
Comment #3.0
Anonymous (not verified) CreditAttribution: Anonymous commentedadditional info
Comment #4
brad.bulger CreditAttribution: brad.bulger commentedSame issue and fix applies in 7.x
Comment #5
tim.plunkettThanks!
Comment #6
ChaseOnTheWeb#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!
Comment #7
David_Rothstein CreditAttribution: David_Rothstein commentedHm... 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.