Frontpage

Drupal 7: delete orphaned comment data

Submitted by Erik Wegner on Sat, 11/10/2012 - 15:17

These commands will delete records from the tables field_data_comment_body and field_data_revision_comment_body, so be advised to make a backup first!

DELETE t1.*
FROM field_data_comment_body t1
    LEFT JOIN comment t2 ON t1.entity_id = t2.cid
WHERE t2.cid IS NULL

DELETE t1.*
FROM field_revision_comment_body t1
    LEFT JOIN comment t2 ON t1.entity_id = t2.cid
WHERE t2.cid IS NULL

OPTIMIZE TABLE `field_data_comment_body` ,
`field_revision_comment_body`

Ratings deleted

Submitted by Erik Wegner on Sun, 07/03/2011 - 14:43
Aufmacherbild

The tips on this page can be rated with the fivestar widget. It now happend that more and more entries got a very bad rating. As a result, the list of good rated articles on the front page shortened and became just on entry.