function comment_delete_multiple
7.x comment.module | comment_delete_multiple($cids) |
Delete comments and all their replies.
Parameters
$cids: The comment to delete.
6 calls to comment_delete_multiple()
- CommentInterfaceTest::setEnvironment in drupal-7.x/
modules/ comment/ comment.test - Re-configures the environment, module settings, and user permissions.
- comment_admin_overview_submit in drupal-7.x/
modules/ comment/ comment.admin.inc - Process comment_admin_overview form submissions.
- comment_delete in drupal-7.x/
modules/ comment/ comment.module - Delete a comment and all its replies.
- comment_multiple_delete_confirm_submit in drupal-7.x/
modules/ comment/ comment.admin.inc - Process comment_multiple_delete_confirm form submissions.
- comment_node_delete in drupal-7.x/
modules/ comment/ comment.module - Implements hook_node_delete().
File
- drupal-7.x/
modules/ comment/ comment.module, line 1616 - Enables users to comment on published content.
Code
function comment_delete_multiple($cids) {
$comments = comment_load_multiple($cids);
if ($comments) {
$transaction = db_transaction();
try {
// 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);
module_invoke_all('entity_delete', $comment, '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);
}
}
catch (Exception $e) {
$transaction->rollback();
watchdog_exception('comment', $e);
throw $e;
}
}
}