From 3ed14ae7823cc2ec58aa8359781d35ab208fc11b Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Jul 2017 00:10:07 -0500 Subject: [PATCH] Post#expunge!: wrap in transaction. --- app/models/post.rb | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 0c99784c9..8dfe1e177 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1379,17 +1379,20 @@ class Post < ApplicationRecord return false end - ModAction.log("permanently deleted post ##{id}") - delete!("Permanently deleted post ##{id}", :without_mod_action => true) - Post.without_timeout do - give_favorites_to_parent - update_children_on_destroy - decrement_tag_post_counts - remove_from_all_pools - remove_from_fav_groups - remove_from_favorites - destroy - update_parent_on_destroy + transaction do + Post.without_timeout do + ModAction.log("permanently deleted post ##{id}") + delete!("Permanently deleted post ##{id}", :without_mod_action => true) + + give_favorites_to_parent + update_children_on_destroy + decrement_tag_post_counts + remove_from_all_pools + remove_from_fav_groups + remove_from_favorites + destroy + update_parent_on_destroy + end end end