When creating a node and translating it the cache for the original node doesn't get reset. So both the translate tab shows a add translation link in the translate tab on the original node.

In the cache the node doesn't have a tnid so it shows the add translation link instead of the translated node.

To reproduce:
1. Enable entity cache
2. Enable i18n and set a node type to be multilanguage with translations
3. Have 2 enabled languages
4. Create a node in language 1
5. Translate that node through translate tab
6. Go to the translate tab on the original node(Langauge 1). It will show a "add translation" link even though there is a translation in the db and you can't create a translation.
7. Clear cache and see the "add translation" link disappear.

Files: 
CommentFileSizeAuthor
#35 add-translation-information-on-each-request-1349566-35-tests-only.patch743 bytesDevin Carlson
PASSED: [[SimpleTest]]: [MySQL] 6,393 pass(es).
[ View ]
#23 add-translation-information-on-each-request-1349566-23.patch1.62 KBjrbeeman
PASSED: [[SimpleTest]]: [MySQL] 6,361 pass(es).
[ View ]
#20 clear-cache-when-translating-1349566-19.patch1.24 KBlex0r
FAILED: [[SimpleTest]]: [MySQL] 6,360 pass(es), 1 fail(s), and 0 exception(s).
[ View ]
#12 add-translation-information-on-each-request-1349566-12.patch1.55 KBDevin Carlson
PASSED: [[SimpleTest]]: [MySQL] 6,361 pass(es).
[ View ]

Comments

david.gil’s picture

same here!

webflo’s picture

Issue tags:+i18n compatibility

Tagging.

webflo’s picture

Version:7.x-1.1» 7.x-1.x-dev

Cannot reproduce with the latest version of i18n. Please update to i18n-7.x-1.3.

webflo’s picture

Ohh no. You are right. There are some issues. I am working on it.

webflo’s picture

david.gil’s picture

Hi, Any advance with this, i cannot figure what to do to enable entity cache with i18n active. if you give me some orientation i can try to solve it...

Best
David

drasgardian’s picture

That patch does appear to solve this issue for me. Although from the look of the #1405234: Implement update hooks for node translation sets. Clean-up node translation sets. thread it doesn't sound like it will be the final solution.

edit - actually I was mistaken, that patch didn't solve it at all.

drasgardian’s picture

I had success with this patch: http://drupal.org/node/1463402#comment-6137776

DamienMcKenna’s picture

drasgardian’s picture

Not really. This issue relates to traditional node translation, whereas #1851430: cache per language relates to translations within a single node, i.e. using the entity_translation module.

Devin Carlson’s picture

Status:Active» Needs review
StatusFileSize
new743 bytes
PASSED: [[SimpleTest]]: [MySQL] 6,388 pass(es).
[ View ]
new1.55 KB
PASSED: [[SimpleTest]]: [MySQL] 6,361 pass(es).
[ View ]

I ran into this while investigating #2070127: Source translated wiki page is not connected to translated pages. The issue can be demonstrated by running the core Translation module's test cases with Entity Cache enabled.

I believe the solution would be to force the translation information to be added on each request, à la book_node_load() in book_entitycache_node_load(), to avoid expensive cache clearing in order to get "accurate" translation information.

Status:Needs review» Needs work
Devin Carlson’s picture

Status:Needs work» Needs review
lmeurs’s picture

@Devin Carlson: I just manually added the translation_entitycache_node_load() implementation from #12 and it works for me so far!

operations’s picture

Patch #13 translation_entitycache_node_load() works for me also..

Pomliane’s picture

Issue summary:View changes
Status:Needs review» Reviewed & tested by the community

Works well here too. Thanks @Devin Carlson.

lex0r’s picture

Hi guys,
what about not doing extra queries each time node is loaded from cache? I will post a solution soon. The idea is to clear entity cache when entity is translated. We do it once and then there's no need to query database each time - PROFIT :)

lex0r’s picture

Here is a patch that evades doing unnecessary selects each time a node is loaded from cache (slightly better performance than #12).

lex0r’s picture

StatusFileSize
new1.24 KB
FAILED: [[SimpleTest]]: [MySQL] 6,360 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

Sorry, didn't figure it out how to add comments and files :)

Status:Reviewed & tested by the community» Needs work

The last submitted patch, 20: clear-cache-when-translating-1349566-19.patch, failed testing.

The last submitted patch, 20: clear-cache-when-translating-1349566-19.patch, failed testing.

jrbeeman’s picture

Status:Needs work» Needs review
StatusFileSize
new1.62 KB
PASSED: [[SimpleTest]]: [MySQL] 6,361 pass(es).
[ View ]

Re-roll patch from #12 against latest 7.x-1.x-dev

lex0r’s picture

@jrbeeman, you didn't like SQL-less solution from #20?

sebdec’s picture

the patch in #23 works whith the node translations (tnid), thanks!

whe have the same problem with the terms translations and the field tsid

maggie_drupal’s picture

I have the same problem and I don't have Entity Cache enabled.
Drupal 7.25

Cyclodex’s picture

We also have the same issue, on our latest projects, but don't have entity cache enabled. So the bug could be somewhere else so it looks... Lets see if we can find out something, but nobody has an idea yet about that?
We probably should make a separate ticket which does show how to reproduce the problem without entity cache...

Cyclodex’s picture

For those who don't use "entity cache" module and are having this issue:

Looks like I found the issue, please see this ticket here which solves the problem for me.
See comment 24 which has the patch (and seems to be in the current dev release of i18n).

This, or my issue, also had nothing to do with the "entity cache" module. (not using it)

torotil’s picture

I'd prefer the solution from #20, because it doesn't slow-down node loads. Any idea why the test fails?

hefox’s picture

#1932954: Source node missing added translation

Looking for a core bug report because this /is/ a core bug

It updates the node table in translation but never resets the cache for that node.

<?php
/**
 * Implements hook_node_insert().
 */
function translation_node_insert($node) {
 [...]
       
// Create new translation set, using nid from the source node.
       
$tnid = $node->translation_source->nid;
       
db_update('node')
          ->
fields(array(
           
'tnid' => $tnid,
           
'translate' => 0,
          ))
          ->
condition('nid', $node->translation_source->nid)
          ->
execute();
      }
?>
hefox’s picture

Can anyone review the core issue?

jweowu’s picture

Devin Carlson’s picture

Status:Postponed» Needs review
StatusFileSize
new743 bytes
PASSED: [[SimpleTest]]: [MySQL] 6,393 pass(es).
[ View ]

The tests-only patch from #12 now passes, confirming that this was fixed by #1936942: translation_node_insert() updates the node table directly without also flushing the entity load cache.

Re-attaching the tests-only patch from #12 as it would be great to have test coverage for translations but the bug itself is now fixed in Drupal 7 HEAD.

Devin Carlson’s picture

Title:Doesn't work with translation» Add tests for content translation
Category:Bug report» Task
Priority:Normal» Minor
Status:Needs review» Reviewed & tested by the community

Retitling issue and lowering priority to accurately reflect the remaining task.