diff options
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r-- | modules/comment/comment.module | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 622433e24..5334c2728 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1583,20 +1583,27 @@ function comment_delete($cid) { 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); - 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); + $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; } } } |