Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When Node export is configured to create a new revision when importing a node that already exists, and this node has a menu, the menu entry is created again.
Here is how to replicate:
- Create node (on site A) and attach it to the main menu.
- Export the node
- Configure Node export (on site B) to create new revisions and to not reset the menu for the content type
- On site A edit the node and export it again
- On site B import the node again.
- A new revision will have been created and a duplicate menu is added.
As far as I can see, this is because the menu item in the menu always has 'mlid' set to 0 when the node is imported. menu.module uses this value to check if a new menu_link should be created by running an sql query with the mlid value (menu.module around line 3027).
To fix this Node export should, in case when a new revision is created, somehow restore the mlid value to the original value.
Comments
Comment #1
artematem CreditAttribution: artematem commentedI managed to avoid this with hook_node_export_node_import_alter()
But in url_alias still appears records with duplicate source, alias and language.
Comment #2
artematem CreditAttribution: artematem commentedIn this case we will skip menu and path values. Will not create duplicates in menu and in url_alias table. Works if you don't need to change menu and path parameters in new revision of node.
Comment #3
lil123 CreditAttribution: lil123 commentedHi,
Is there any news about this problem? Maybe a patch? Ideally, I would need to have the changes made on menu title or path to be exported.
Thank you for your help
Comment #4
danielb CreditAttribution: danielb commentedThere have been a few changes regarding menus lately, but if this is still a problem in the new code please reopen.