A platform for community discussion. Free, open, simple.
FIX: Topic is nil when first post is being created
David Taylorb373ff47e2a9
diff --git a/lib/validators/post_validator.rb b/lib/validators/post_validator.rbindex 9c43cf07d67..b441ecc0328 100644--- a/lib/validators/post_validator.rb+++ b/lib/validators/post_validator.rb@@ -146,7 +146,7 @@ class Validators::PostValidator < ActiveModel::Validatorreturn if SiteSetting.max_consecutive_replies == 0 || post.id || post.acting_user&.staff? || private_message?(post)topic = post.topic- return if topic.posts.first&.user == post.user+ return if topic&.first&.user == post.userlast_posts_count = DB.query_single(<<~SQL, topic_id: post.topic_id, user_id: post.acting_user.id, max_replies: SiteSetting.max_consecutive_replies).firstSELECT COUNT(*)