We recently updated entity translation from dev+14 to dev+17, and since than when we press the translate tab the translations are getting deleted from the db (No log message in watchdog).
On the current dev version (dev+21) it is also still happening.

We haven't figured out how or when yet. We will try to do some more research how this is happening, once we have recovered all lost translations.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Martijn Houtman’s picture

It appears (not 100% sure yet) the records from the 'entity_translation' table are deleted, while the field_data_* records are still intact.

plach’s picture

Priority: Critical » Major
Status: Active » Postponed (maintainer needs more info)

This is obviously something the does not happen in every site, so demoting to major. The only write operation that is triggered when accessing the translation overview page is translation initialization. I guess if there is something messed up in your installation this operation might end up deleting translation records. See:

http://cgit.drupalcode.org/entity_translation/tree/entity_translation.ad...
http://cgit.drupalcode.org/entity_translation/tree/includes/translation....

clairedesbois@gmail.com’s picture

Hello everyone,

The problem is complicated, I've made a quickly patch before Christmas to avert the problem but it doesn't repair broken entities.

When you have updated to dev+17, in entity_translation_update_7006(), the revision for entity translation is activated. If you don't have translations yet, it works, you have no problem. But, if you have translations before, when you go in Translate tab for an entity, some actions are call:
loadTranslations() in translation.handler.inc retrieves the translation for entity. After, translations are resaved with saveTranslations() in entity_translation and entity_translation_revision tables after deletion (why, I don't know).
Problem: If revision for entity translation is activated, the translation (not for source language) is retrieved in entity_translation_revision table. But, when revisions are activated in entity_translation_update_7006, this table is empty. So, it doesn't recreate translations in entity_translation and entity_translation_revision.

My patch just deactivates revisions for entity_translation, transfers translation in entity_translation_revision table (and updates entity_translation table too) and reactivates revisions. But, for your broken entities, you must create a batch function to recreate translations and revisions which have been deleted when you have visited the translation tab.

You can also deactivated entity_translation_revision_enabled variable with 0 to don't broken other entities.

clairedesbois@gmail.com’s picture

Status: Postponed (maintainer needs more info) » Needs review

Status: Needs review » Needs work
matsbla’s picture

I updated from 7.x-1.0-beta3 to 7.x-1.0-beta3+24-dev to test the new entity translation revision feature

I run update.php:
7005 - Rebuild the class registry to pick up the translation handler factory class.
7006 - Add revision schema for entity translation metadata.

After all translations done with entity translation are gone.

erwangel’s picture

Same problem here. Translations don't appear in content>translate tab although they are still present in field_data_*, field_revision_* and also in entity_translation table as well as in entity_translation_revision table. However, not all translations are present there in entity_translation and even less in entity_translation_revision. Although there is a logic in the entity_translation_revision (one record per entity present, but we need one record per translation as calystod said in #3), I can't see any logic on the records that are present in entity_translation (some entities have only one record with the original version, some others have one record for every translation). It looks like some records were deleted, but I can't understand when and why. I didn't try to (re)save any of the concerned entities since the update to the 7.x-1.0-beta3+24-dev (from a previous dev version). I've only visited the translation tab. So the only cause I see for the disappearance of the missing record is during the update.

Also the tnid column of node table which is supposed to hold the translation is set to 0. Setting it manually to the node id of source of entity_translation didn't change anything: translation still don't appear. I'm not sure the tnid column is part of the entity translation module and I didn't find any reference to it in entity_translation.install

I didn't try Calysto's patch (#4) but as I have only a dozen of nodes in translated mode I followed manually the steps she described in #4 and created missing records in entity_translation table then created the corresponding records in entity_translation_revision then verified/updated entity_translation and then... miracle, my translation appeared and everything came back as before ! Merry Christmas / Joyeux Noël !

P.S.: It seems that it is not necessary to have a record per translation in entity_translation table ; I tested having one record per translation only in the entity_translation_revision table and it works. I didn't search further to understand the logic, so finally I preferred create one record per translation in both tables.

plach’s picture

Title: Translations deleted » [DATA LOSS] Translations deleted
Priority: Major » Critical
Issue tags: +beta blocker

Mmh, it seems there's something wrong with the update functions, I will investigate this ASAP.

  • plach authored cb6a137 on 7.x-1.x
    Issue #2396103 by plach: Fixed [DATA LOSS] Translations deleted
    
plach’s picture

Status: Needs work » Needs review
FileSize
1.54 KB

When adding revision support for translation metadata I decided to leave it disabled on existing sites, as upgrading translation metadata in an update function is something I definitely don't want to support, since I am not even sure it's actually feasible in a reliable way.

Unfortunately I didn't review #2382713: entity_translation_update_7006 fails because of SQL error before variable_set('entity_translation_revision_enabled', FALSE); can run. carefully enough: that patch basically enables revision support on any installation performing update 7006, which was definitely not my original plan, although I did not imagine the consequences could be so disruptive. Just one clarification: "only" translation metadata is currently being deleted, but the actual field values are still there, they are just hidden because ET no longer knows they are there, so by disabling revision support and recreating the records in the {entity_translation} table it's possible to make them come back.

I just committed and pushed the attached patch, which disables revision support again. It will not restore lost data, although I seriously hope people did not test this on live sites without making a backup, but it will prevent other sites from breaking. People wishing to enable revision support on existing sites will have to perform the upgrade manually by creating a record in the {entity_translation_revision} table for each available entity revision. I'd suggest to simply copy values from the {entity_translation} table.

I will leave this open for now, so people can confirm existing sites keep working as before. Feel free to ask any clarification you may need to make your sites functional again.

Status: Needs review » Needs work

The last submitted patch, 10: et-revision_disable-2396103-9.patch, failed testing.

plach’s picture

Status: Needs work » Needs review
badrange’s picture

Backups are great, but I don't always go and edit a node's translations after each upgrade.

I haven't performed the update, but I ran drush vset entity_translation_revision_enabled FALSE and created a lot of insert sqls for the different nodes into the entity_translation table, and lo and behold things seem to work as expected.

clairedesbois@gmail.com’s picture

I've open a new issue to work on activation of revisions for entity translation.

https://www.drupal.org/node/2402247

plach’s picture

Status: Needs review » Fixed

I tested the update again both via drush and via the UI. Things seem work fine so marking fixed.

Please confirm if you have a chance, beta4 will be out soon.

Roderik de Langen’s picture

I would be happy to test it, which patch should i apply, or when is the fix in the latest dev version?

plach’s picture

The patch was committed days ago, so the latest dev should be fine...

Roderik de Langen’s picture

I tested it and this fix seems to be working
nice work!

Status: Fixed » Closed (fixed)

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

juhog’s picture

A quick note about a problem I encountered with this update.

Feeds 2.0-beta3 + Enitity Translation 1.0-beta5 ended up being incompatible on our system.

Feeds 2.0-beta3 introduces a new entity language setting. Feeds would update our taxonomy term data into a format which does not suit the new code of Entity Translation 1.0-beta5.

stefanos.petrakis@gmail.com’s picture

Hey @juhog, thanks for the quick note.
You should open a new ticket for this if you think it needs one, with some more info about the issue you encountered, would be helpful. And reference this - closed - issue if they are related.
Thanks!