Download & Extend

Do not synchronize if no field has changed

Project:Internationalization
Version:6.x-1.5
Component:Blocks
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

On http://musescore.org , there is a pretty extensive collaboration on only one 'book' which is translated in several languages. Synchronization is set on two fields only: book outline and file attachments.

When updating a book page, the i18nsync module updates all node translations as well and a new revision is created. This could be the desired behavior but in case no fields are changed (book outline or file attachments), one could wish that the translated nodes are not updated. The main reason: each of the new revisions shows up in the recent changes page (recent_changes module) but the diff does not show any difference and the log is empty. This is very confusion for collaborative book translation.

The solution is to prevent the i18nsync doing it's work if no fields of the updated node have been changed.
The attached patch implements a 'presave' op for the hook_nodeapi in which the fields are checked whether they are actually changed or not. For the moment, only the files & default field are checked so the patch needs more work. However, I would like to get feedback whether the patch could make it into the CVS.

AttachmentSizeStatusTest resultOperations
i18nsync.patch2.01 KBIgnoredNoneNone

Comments

#1

The basic idea seems worthwhile.

I don't think we need the complex handling of each field though. I suspect we could just:

* determine the fields that should be syncrhonized
* for each one, test whether the $old_node->$field = $node>$field.
* if all match, don't synch.

#2

It looks like a good solution. Can you add it to the module?

#3

Status:active» needs work

The patch needs work, further improvements and decent testing for all possible sync fields. But I can say it does run already in production for quite some time now.

#4

subscribe

#5

Version:6.x-1.0-beta6» 6.x-1.5
Status:needs work» needs review

The patch doesn't work for me as comparing CCK field is almost impossible on form submission. They contain all kind of junk, e. g. "_error_element" and are therefore flagged as different.

In this patch, there's a different approach. Basically a snapshot of the previous state (before saving) of the node object is taken in 'presave' of hook_nodeapi(). The majority of the previous code is moved into 'update'.

AttachmentSizeStatusTest resultOperations
i18nsync-prevent-sync-if-no-field-change.patch4.81 KBIgnoredNoneNone

#6

Component:Code» Blocks

I noticed that using rules module to set custom breadcrumb on translatable nodes triggers translation synchronization. This results in a message box "One node translation has been synchronized" being displayed on every page view -- which is a nuisance. Patch #5 fixes the problem for me - thanks!

nobody click here