A platform for community discussion. Free, open, simple.
FIX: Do not show hidden posts in search results (#26800)
Jan Cernik9fb888923d74
diff --git a/lib/search.rb b/lib/search.rbindex 1a388870243..e38466b01b2 100644--- a/lib/search.rb+++ b/lib/search.rb@@ -1076,7 +1076,7 @@ class Searchdef posts_query(limit, type_filter: nil, aggregate_search: false)posts =- Post.where(post_type: Topic.visible_post_types(@guardian.user)).joins(+ Post.where(post_type: Topic.visible_post_types(@guardian.user), hidden: false).joins(:post_search_data,:topic,)diff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rbindex 79f18740124..2d781b4bd6d 100644--- a/spec/lib/search_spec.rb+++ b/spec/lib/search_spec.rb@@ -1026,6 +1026,13 @@ RSpec.describe Search doexpect(results.posts).to eq([post])end+ it "does not return hidden posts" do+ Fabricate(:post, raw: "Can you see me? I'm a hidden post", hidden: true)++ results = Search.execute("hidden post")+ expect(results.posts.count).to eq(0)+ end+it "does not rely on postgres's proximity opreators" dotopic.update!(title: "End-to-end something something testing")