Problem/Motivation

When cloning a node with the Node clone module (version 7.x-1.0) or importing a node with the Node export module (version 7.x-3.1), the new (cloned/imported) node contains much of the metadata from the previous node, including enough of the translation metadata for the entity_translation module to mistake the save operation for an update to the previous node's translation.

We do want to keep most of the original node's translation data; but we want the insert translation hooks to run, instead of the update hooks.

Among other things, this impacts the Search API Entity Translation module, which will only add nodes to the search index when entity_translation's insert hook (i.e.: hook_entity_translation_insert()) fires.

Proposed resolution

Implement hook_clone_node_alter() and explicitly set $node->translations->hook[$langcode]['hook'] = 'insert'; for each translation.

Remaining tasks

  1. Write a patch
  2. Review and feedback
  3. RTBC and feedback
  4. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mparker17 created an issue. See original summary.

mparker17’s picture

Issue summary: View changes

(minor formatting changes to the issue summary)

mparker17’s picture

Assigned: mparker17 » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
1.02 KB

Here's a patch! Feedback welcome!

mparker17’s picture

Assigned: Unassigned » mparker17
Status: Needs review » Needs work

As discussed in #2866487: Node export: make cloning a node count as inserting a new translation instead of updating the original node's translation, I've noticed the same underlying problem when importing a node using the Node export module (version 7.x-3.1). The solution is the same as well.

Going to update this patch to support that module too.

mparker17’s picture

Here's a preliminary patch; but leaving it as "needs work" so I can move the common code into a common helper function.

mparker17’s picture

Assigned: mparker17 » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.61 KB
1.91 KB

Okay, here's an updated patch. Feedback welcome.