Problem/Motivation

When a node is saved with "Provide a menu link" checked and filled in the token is generated based on the values in the form. When a node is saved outside the form it is generated based on menu_ui_get_menu_link_defaults via _token_menu_link_best_match which gets the "Best" menu link for the node.

If a menu item is removed by unchecking "Provide a menu link", token falls back to menu_ui_get_menu_link_defaults and finds the original menu link, which is removed after save leading to an incorrect token replacement.

Steps to reproduce

  1. Set a pathauto pattern to /[node:menu-link:menu:machine-name]/[node:title]
  2. Save a node with "Provide a menu link" checked
  3. Node path should be prefixed with the menu name
  4. Edit the node and uncheck "Provide a menu link"
  5. Node path will incorrectly still be prefixed with the menu name
  6. Edit the node and save without changes
  7. Node path will be corrected to remove the menu name

Proposed resolution

Use $node->menu to filter the results from menu_ui_get_menu_link_defaults

$node->menu has the values of the form. If it was just disabled the previous id will still be there for reading, but I'm not sure if this is a documented API or undefined behavior.

CommentFileSizeAuthor
#3 3564077.patch2.23 KBshank115

Comments

jvollebregt-swis created an issue. See original summary.

santanu mondal’s picture

Working on it..

shank115’s picture

Status: Active » Needs review
StatusFileSize
new2.23 KB

Try this patch. Also in /admin/config/search/path/settings check 'delete old alias' is selected.