From 2e02a28ab4f51335c9caea487622eb286ed7397b Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Fri, 21 Sep 2018 14:04:45 +0530 Subject: [PATCH] FIX: do not revise post if post revision is not present --- lib/post_destroyer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index 3b68fc60aa9..94146ffb323 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -162,7 +162,8 @@ class PostDestroyer 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) + last_revision = @post.revisions.last + @post.revise(@user, { raw: last_revision.modifications["raw"][0] }, force_new_version: true) if last_revision.present? end private