From 6e4ff45e4419096ebbe47101528acaee1e76098a Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 22 Jun 2016 17:28:46 +1000 Subject: [PATCH] FIX: deleting a topic result not updated on screen --- .../javascripts/discourse/controllers/topic.js.es6 | 1 - lib/post_destroyer.rb | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 0062c13bd..76d64427e 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -758,7 +758,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { }, deleteTopic() { - this.unsubscribe(); this.get('content').destroy(Discourse.User.current()); }, diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index b1538585a..c0ac588d9 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -109,8 +109,11 @@ class PostDestroyer # When a user 'deletes' their own post. We just change the text. def mark_for_deletion I18n.with_locale(SiteSetting.default_locale) do + + # don't call revise from within transaction, high risk of deadlock + @post.revise(@user, { raw: I18n.t('js.post.deleted_by_author', count: SiteSetting.delete_removed_posts_after) }, force_new_version: true) + Post.transaction do - @post.revise(@user, { raw: I18n.t('js.post.deleted_by_author', count: SiteSetting.delete_removed_posts_after) }, force_new_version: true) @post.update_column(:user_deleted, true) @post.update_flagged_posts_count @post.topic_links.each(&:destroy) @@ -122,9 +125,11 @@ class PostDestroyer Post.transaction do @post.update_column(:user_deleted, false) @post.skip_unique_check = true - @post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true) @post.update_flagged_posts_count end + + # has internal transactions, if we nest then there are some very high risk deadlocks + @post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true) end private