Skip to content

A platform for community discussion. Free, open, simple.

FIX: Use safe navigation operator throughout statement

David Taylor4831c4c2eeef
diff --git a/lib/validators/post_validator.rb b/lib/validators/post_validator.rb
index 0629b7cc550..9c1e7fe3b04 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&.posts&.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(*)