From 69661be500bb01c0be7fa2c1ff402fcf8ba3c45b Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 4 Apr 2017 14:29:47 +0800 Subject: [PATCH] FIX: Don't raise an error if `TopicStatusUpdate` has been deleted. --- app/jobs/regular/toggle_topic_closed.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/jobs/regular/toggle_topic_closed.rb b/app/jobs/regular/toggle_topic_closed.rb index 84b946fd8ad..150df7625c8 100644 --- a/app/jobs/regular/toggle_topic_closed.rb +++ b/app/jobs/regular/toggle_topic_closed.rb @@ -2,15 +2,15 @@ module Jobs class ToggleTopicClosed < Jobs::Base def execute(args) topic_status_update = TopicStatusUpdate.find_by(id: args[:topic_status_update_id]) - raise Discourse::InvalidParameters.new(:topic_status_update_id) if topic_status_update.blank? - - return if topic_status_update.execute_at > Time.zone.now - - topic = topic_status_update.topic - return if topic.blank? - state = !!args[:state] - return if topic.closed == state + + if topic_status_update.blank? || + topic_status_update.execute_at > Time.zone.now || + (topic = topic_status_update.topic).blank? || + topic.closed == state + + return + end user = topic_status_update.user