comment_delete_multiple

Versions
mediamosa-21
comment_delete_multiple($cids)

Delete comments and all their replies.

Parameters

$cids The comment to delete.

▾ 6 functions call comment_delete_multiple()

comment_admin_overview_submit in modules/comment/comment.admin.inc
Process comment_admin_overview form submissions.
comment_delete in modules/comment/comment.module
Delete a comment and all its replies.
comment_delete_multiple in modules/comment/comment.module
Delete comments and all their replies.
comment_multiple_delete_confirm_submit in modules/comment/comment.admin.inc
Process comment_multiple_delete_confirm form submissions.
comment_node_delete in modules/comment/comment.module
Implements hook_node_delete().
comment_user_delete in modules/comment/comment.module
Implements hook_user_delete().

Code

modules/comment/comment.module, line 1518

<?php
function comment_delete_multiple($cids) {
  $comments = comment_load_multiple($cids);
  if ($comments) {

    // Delete the comments.
    db_delete('comment')
      ->condition('cid', array_keys($comments), 'IN')
      ->execute();
    foreach ($comments as $comment) {
      field_attach_delete('comment', $comment);
      module_invoke_all('comment_delete', $comment);

      // Delete the comment's replies.
      $child_cids = db_query('SELECT cid FROM {comment} WHERE pid = :cid', array(':cid' => $comment->cid))->fetchCol();
      comment_delete_multiple($child_cids);
      _comment_update_node_statistics($comment->nid);
    }
  }
}
?>