Symptom:
Adding a translation creates a new node in the target language that is not properly tied to the original source node. Specifically, the source node’s tnid-field is not set, preventing the translated and the original version from showing up as localized version of the same content.

Problem Description:
In certain setup configurations, the node_load() call in line 254 of the i18nsync.module (i18nsync_node_translation) can bring up a cached version of the source node for a translation. This cached version then does not have the tnid-field properly set, resulting in the function’s node_save operation (line 320) overwriting any previously set tnid-field.

Detailed Example Scenario:
If a node-form does not encourage caching of the form, the include/form.inc will perform a node_load() operation, thus allowing node_load() to cache the node. When the translation.module then performs an “UPDATE node SET tnid = x, translate = 0 WHERE nid = x;” this does not impact the cached version of the node. The i18nsync.module’s node_load() then brings up the cached version without the tnid-field set. Upon saving the node, the above UPDATE command's results get overwritten.

Fix:
The easiest and most graceful fix might be to modify the node_load() call in line 254 of the i18nsync.module. Replace
$translation = node_load($translation->nid);
by
$translation = node_load($translation->nid, NULL, TRUE);
to force node_load to use the (up-to-date) database-version of the node instead of the cached one.

CommentFileSizeAuthor
#2 367118.patch1.2 KBBevan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

HnLn’s picture

I can confirm this is the same issue as http://drupal.org/node/364319 (which is for the 5.x.3 version).

FYI, it's the exact same change on line 139 of the i18nsync.module.

HnLn

Bevan’s picture

Title: Form Caching Problem with i18nsync.module » Translation relationship broken with i18nsync
Status: Active » Reviewed & tested by the community
FileSize
1.2 KB

I turned this into a patch. It worked for me and fixed the issue. I also marked #361625: Translation nodes are lost if interface language == language translated to duplicate, and modified #364319: Translation relationship broken with i18nsync (Drupal 5 backport) as the drupal 5 backport.

Jose Reyero’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

David Lesieur’s picture

Status: Closed (fixed) » Active

Btw, although this patch works, it only solves the problem on the surface. The real issue — the reason why node_load() does not return fresh data as one would expect — seems to be in translation.module; see #398428: node_load's static cache is outdated when bypassed by a direct modification to the "node" table..

azoho’s picture

Hi, I've attempted this patch to line 254 of i18nsync.module

$translation = node_load($translation->nid, NULL, TRUE);

and I have run upgrade.php to clear the cache, but I am still having the problem of the translation not being linked to the source and vice versa.

I'm really stuck on this and need it to work as the site is multilingual
I'm running Drupal 6.11 and i18n 6.x-1.0

I have cache turned off in the Drupal site configuration if that is the same as the database cache
Tried turning off and on Synchronize translations module with no luck.

najibx’s picture

Hi ...I have Synchronize translations (disabled), but still losing the relationship? is there other isssues, in addition to Synchronize translations?

TQ

najibx’s picture

in my case, I created a Rules that triggered "After saving new content". Removing this Rules seems fixed the problem. Others reported the same problem with Workflow module. However, I still need this Rules. Can anyone direct me a solution. TQ

reported here http://drupal.org/node/484870

Jose Reyero’s picture

Component: Code » Blocks
Status: Active » Closed (won't fix)

Closing issues open for more than a year without follow up. Cleaning up the issue tracker.

Cyclodex’s picture

If you come over this ticket if you have current issues in D7 with i18n 7.x-1.10 , this ticket #2058685 seems to fix the problem (in dev release right now).
It is also not dependent on the "entity cache" module, its just some reset of cache in the "entity" module itself.