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

I managed to avoid this with hook_node_export_node_import_alter()

function MODULE_node_export_node_import_alter(&$node, $original_node, $save) {
$path = 'node/' . $node->nid;
  if (drupal_get_path_alias($path) != $path) {
  $node->menu = NULL;
  }
}

But in url_alias still appears records with duplicate source, alias and language.

function MODULE_node_export_node_import_alter(&$node, $original_node, $save) {
  $path = 'node/' . $node->nid;
  if (drupal_get_path_alias($path) != $path) {
    $node->menu = NULL;
    $node->path = NULL;
  }
}

In 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.

Issue summary:View changes

Hi,

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