function comment_delete_multiple

cis7 comment.module comment_delete_multiple($cids)
cle7 comment.module comment_delete_multiple($cids)
elmsmedia7 comment.module comment_delete_multiple($cids)
icor7 comment.module comment_delete_multiple($cids)
meedjum_blog7 comment.module comment_delete_multiple($cids)
mooc7 comment.module comment_delete_multiple($cids)

Delete comments and all their replies.

Parameters

$cids: The comment to delete.

5 calls to 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_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().

File

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;
    }
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.