Same name and namespace in other branches
  1. 4.6.x modules/comment.module \_comment_delete_thread()
  2. 5.x modules/comment/comment.module \_comment_delete_thread()
  3. 6.x modules/comment/comment.admin.inc \_comment_delete_thread()
2 calls to _comment_delete_thread()
comment_confirm_delete_submit in modules/comment.module
comment_multiple_delete_confirm_submit in modules/comment.module
Perform the actual comment deletion.

File

modules/comment.module, line 1623
Enables users to comment on published content.

Code

function _comment_delete_thread($comment) {
  if (!is_object($comment) || !is_numeric($comment->cid)) {
    watchdog('content', t('Can not delete non-existent comment.'), WATCHDOG_WARNING);
    return;
  }

  // Delete the comment:
  db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
  watchdog('content', t('Comment: deleted %subject.', array(
    '%subject' => theme('placeholder', $comment->subject),
  )));
  comment_invoke_comment($comment, 'delete');

  // Delete the comment's replies
  $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid);
  while ($comment = db_fetch_object($result)) {
    $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
    _comment_delete_thread($comment);
  }
}