Reproduce:
1) Enable translations with a minimum of three languages.
2) Create a node in all three languages.
3) Delete one of the nodes in the set - not the source node though!

Expected:
The two nodes not deleted would still be in a translation set.

Result:
All nodes are removed from the translation set, due to a wrong counter in the first condition. The code presumes the node you are deleting isn't removed from the database yet. But it is :-)

Fix:
Change "<= 2" to "== 1".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nedjo’s picture

Title: All tranalations are removed from set when deleting one node » All translations are removed from set when deleting one node
Status: Needs review » Reviewed & tested by the community
FileSize
1.01 KB

Yes, this is a bug and the solution is correct.

This bug occurs only when a translation is deleted leaving exactly two translations in a translation set.

As well as the reported problem, this bug will prevent proper changing of the source translation under this condition.

Further details:

translation_remove_from_set() is called by the 'delete' op of hook_nodeapi(), which is called after the node has been deleted from the node table. Hence, we indeed need to test for a single remaining member of the translation set, not two or fewer remaining members as is currently done.

Tested before the patch and reproduced the issue. Tested after the patch and the issue was resolved.

I've modified a code comment to reflect the change.

This patch should be applied also to the Drupal 6 branch.

nedjo’s picture

Version: 6.2 » 7.x-dev

Patch is on HEAD.

webchick’s picture

Version: 7.x-dev » 6.x-dev

Woah. That's a tweaky problem. :P I wonder why the current code was there to begin with? Seems like a very awkward way to say "If there are no more translations, then..." Hm.

Well, I've committed to 7.x, and moved this back to 6.x. So hopefully Gábor can tell us. :D

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed to Drupal 6. Unfortunately the order of hook calls and actions is not too consistent. Some hooks are called before the action is going to be done, some hooks are called after.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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