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
Write a patch- Review and feedback
- RTBC and feedback
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#6 | 2859325-6-clone-or-import-are-new-translations.patch | 1.61 KB | mparker17 |
|
Comments
Comment #2
mparker17(minor formatting changes to the issue summary)
Comment #3
mparker17Here's a patch! Feedback welcome!
Comment #4
mparker17As 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.
Comment #5
mparker17Here's a preliminary patch; but leaving it as "needs work" so I can move the common code into a common helper function.
Comment #6
mparker17Okay, here's an updated patch. Feedback welcome.