We have enabled i18n_sync on a rather large site of ours recently. This is the problem as best as I can describe it:
We have a content type with certain fields that are synchronised with i18n_sync. Upon making a change to the primary node (i.e. tnid == nid), we notice that everything functions as per normal. But when I make a change to one of the translations (i.e. tnid != nid), we enter a recursive loop of i18n_sync saving the translation, then the primary node, then the translation and so on. This occurs about 70 times from my testing:
[i18n_sync.module:237] # syncing is enabled!
[i18n_sync.module:238] # count is 67
[i18n_sync.module:245] preparing to sync 2834
[i18n_sync.module:241] # syncing is disabled!
[i18n_sync.node.inc:67] Saving nid 2833
[i18n_sync.node.inc:68] float(473.67)
[i18n_sync.node.inc:72] done
[i18n_sync.node.inc:73] float(473.9)
[i18n_sync.module:237] # syncing is enabled!
[i18n_sync.module:238] # count is 68
[i18n_sync.module:245] preparing to sync 2833
[i18n_sync.module:241] # syncing is disabled!
[i18n_sync.node.inc:67] Saving nid 2834
[i18n_sync.node.inc:68] float(492.64)
[i18n_sync.node.inc:72] done
[i18n_sync.node.inc:73] float(492.86)
[i18n_sync.module:237] # syncing is enabled!
[i18n_sync.module:238] # count is 69
[i18n_sync.module:245] preparing to sync 2834
[i18n_sync.module:241] # syncing is disabled!
[i18n_sync.node.inc:67] Saving nid 2833
[i18n_sync.node.inc:68] float(515.46)
[i18n_sync.node.inc:72] done
[i18n_sync.node.inc:73] float(515.69)
[i18n_sync.module:237] # syncing is enabled!
[i18n_sync.module:238] # count is 70
[i18n_sync.module:245] preparing to sync 2833
[i18n_sync.module:241] # syncing is disabled!
[i18n_sync.node.inc:67] Saving nid 2834
[i18n_sync.node.inc:68] float(489.83)
This is obviously less than ideal. I realise there is probably some rouge code in either our custom code, or some contrib, I have tried to track this down to know avail.
My proposed solution is to store a static variable that contains all nids that have been saved so far to date, and to prevent the duplicate saving inside the i18n_sync module itself.
What do you think of the attached patch?
This new functionality could be hidden behind an admin setting, or simply a hidden variable, or it could be the default functionality.
| Comment | File | Size | Author |
|---|---|---|---|
| i18n_sync-prevent-duplicate-saves.patch | 822 bytes | wiifm |
Comments
Comment #1
jose reyero commentedOk with the idea, though I don't like too much the implementation: complex, wrong place, leaves inconsistent api function that returns different values when called twice.
Could we maybe mark the synced node, with somehting like $node->i18n_sync_done = TRUE and then check that?