When you create a node with an assigned language the tnid stays 0 until you actually add a translation to the set. A website can have a lot of nodes that have different languages assigned to nodes, but none would have a translation set, so the tnid stays 0.

The problem is that when a website contains large amount of nodes like these the following call may retrieve hundreds, if not thousands (like in the case of a website I'm working on):

<?php
  $set_nids = db_query('SELECT nid FROM {node} WHERE tnid = :tnid', array(':tnid' => $node->tnid))->fetchCol();
?>

Due to the large amount of data returned by the call deleting a single node can become a very lengthy task that takes up a huge amount of resources.

The patch in the following comment allows to bypass this issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skein’s picture

sandra.ramil’s picture

I had the same problem and this patch worked great for me!!! Thanks!

escuriola’s picture

Works fine for us too.

My teammate had the same problem and finally get the same solution before she found really frustrated that was already done. ;) She was so close to contrib to core...

Regards

matsearle’s picture

Status: Needs review » Reviewed & tested by the community

Since this is a small patch and has already been tested by the community, it would really good if this could be rolled in asap as it would be really helpful to me at least.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

This looks good - it doesn't seem like there are any situations where the code in that function is actually intended to run when $node->tnid is 0.

Committed to 7.x - thanks!

  • David_Rothstein committed b85b146 on 7.x
    Issue #2457743 by skein: translation_remove_from_set() runs unnecessary...

Status: Fixed » Closed (fixed)

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