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.
Comment | File | Size | Author |
---|---|---|---|
#1 | drupal-7.x-do_not_do_remove_set_if_tnid_is_zero-2457743-1.patch | 498 bytes | skein |
Comments
Comment #1
skein CreditAttribution: skein commentedComment #2
sandra.ramil CreditAttribution: sandra.ramil commentedI had the same problem and this patch worked great for me!!! Thanks!
Comment #3
escuriola CreditAttribution: escuriola commentedWorks 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
Comment #4
matsearle CreditAttribution: matsearle commentedSince 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.
Comment #5
David_Rothstein CreditAttribution: David_Rothstein commentedThis 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!