Do not synchronize if no field has changed

toemaz - November 25, 2008 - 03:06
Project:Internationalization
Version:6.x-1.0-beta6
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

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.

AttachmentSize
i18nsync.patch2.01 KB

#1

nedjo - December 12, 2008 - 22:43

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

mcload - January 31, 2009 - 19:38

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

#3

toemaz - February 1, 2009 - 11:41
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

jorgemare - February 4, 2009 - 20:55

subscribe

 
 

Drupal is a registered trademark of Dries Buytaert.