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
- Set a pathauto pattern to
/[node:menu-link:menu:machine-name]/[node:title] - Save a node with "Provide a menu link" checked
- Node path should be prefixed with the menu name
- Edit the node and uncheck "Provide a menu link"
- Node path will incorrectly still be prefixed with the menu name
- Edit the node and save without changes
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3564077.patch | 2.23 KB | shank115 |
Comments
Comment #2
santanu mondal commentedWorking on it..
Comment #3
shank115 commentedTry this patch. Also in /admin/config/search/path/settings check 'delete old alias' is selected.