From b373ff47e2a95ac18129a960b0b64492fe5d1404 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 3 Dec 2018 18:30:52 +0000 Subject: [PATCH] FIX: Topic is nil when first post is being created --- lib/validators/post_validator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/validators/post_validator.rb b/lib/validators/post_validator.rb index 9c43cf07d67..b441ecc0328 100644 --- a/lib/validators/post_validator.rb +++ b/lib/validators/post_validator.rb @@ -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) 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 SELECT COUNT(*)