diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-11-14 20:42:45 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-11-14 20:42:45 +0000 |
commit | 8dd7376d5a15f2485fdd83c8db402a244314e30b (patch) | |
tree | 1b6241df8c5eeb5692e2345144fad8ee435de941 /modules/comment | |
parent | 8049f94756021402a34ad3f2eb54fee5b19ae39b (diff) | |
download | brdo-8dd7376d5a15f2485fdd83c8db402a244314e30b.tar.gz brdo-8dd7376d5a15f2485fdd83c8db402a244314e30b.tar.bz2 |
#923826 by catch, carlos8f, moshe weitzman: Fixed entity delete operations should use transactions.
Diffstat (limited to 'modules/comment')
-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; } } } |