FIX: Don't unassign topic on flag reviewed if topic has been deleted.

* Should have a test for this.
This commit is contained in:
Guo Xiang Tan 2018-05-25 16:40:00 +08:00
parent e1c7869969
commit fe68b6cc88
1 changed files with 2 additions and 1 deletions

View File

@ -215,7 +215,8 @@ after_initialize do
# Unassign if there are no more flags in the topic
on(:flag_reviewed) do |post|
if SiteSetting.assign_locks_flags? &&
FlagQuery.flagged_post_actions(topic_id: post.topic_id).count == 0
post.topic &&
FlagQuery.flagged_post_actions(topic_id: post.topic.id).count == 0
assigner = ::TopicAssigner.new(post.topic, Discourse.system_user)
assigner.unassign