FIX: Topic is nil when first post is being created

This commit is contained in:
David Taylor 2018-12-03 18:30:52 +00:00
parent 4e2cc9caf0
commit b373ff47e2
1 changed files with 1 additions and 1 deletions

View File

@ -146,7 +146,7 @@ class Validators::PostValidator < ActiveModel::Validator
return if SiteSetting.max_consecutive_replies == 0 || post.id || post.acting_user&.staff? || private_message?(post) return if SiteSetting.max_consecutive_replies == 0 || post.id || post.acting_user&.staff? || private_message?(post)
topic = post.topic topic = post.topic
return if topic.posts.first&.user == post.user return if topic&.first&.user == post.user
last_posts_count = DB.query_single(<<~SQL, topic_id: post.topic_id, user_id: post.acting_user.id, max_replies: SiteSetting.max_consecutive_replies).first last_posts_count = DB.query_single(<<~SQL, topic_id: post.topic_id, user_id: post.acting_user.id, max_replies: SiteSetting.max_consecutive_replies).first
SELECT COUNT(*) SELECT COUNT(*)