mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:57:29 +08:00
FIX: invalid cache for parent category with limit_suggested_to_category
This commit is contained in:
parent
41a604a764
commit
38c018a84b
|
@ -6,9 +6,6 @@ class RandomTopicSelector
|
|||
def self.backfill(category = nil)
|
||||
exclude = category&.topic_id
|
||||
|
||||
# don't leak private categories into the "everything" group
|
||||
user = category ? CategoryFeaturedTopic.fake_admin : nil
|
||||
|
||||
options = {
|
||||
per_page: category ? category.num_featured_topics : 3,
|
||||
visible: true,
|
||||
|
@ -16,9 +13,20 @@ class RandomTopicSelector
|
|||
}
|
||||
|
||||
options[:except_topic_ids] = [category.topic_id] if exclude
|
||||
options[:category] = category.id if category
|
||||
|
||||
query = TopicQuery.new(user, options)
|
||||
if category
|
||||
options[:category] = category.id
|
||||
# NOTE: at the moment this site setting scopes tightly to a category (excluding subcats)
|
||||
# this is done so we don't populate a junk cache
|
||||
if SiteSetting.limit_suggested_to_category
|
||||
options[:no_subcategories] = true
|
||||
end
|
||||
|
||||
# don't leak private categories into the "everything" group
|
||||
options[:guardian] = Guardian.new(CategoryFeaturedTopic.fake_admin)
|
||||
end
|
||||
|
||||
query = TopicQuery.new(nil, options)
|
||||
|
||||
results = query.latest_results.order('RANDOM()')
|
||||
.where(closed: false, archived: false)
|
||||
|
|
|
@ -43,6 +43,7 @@ class TopicQuery
|
|||
page
|
||||
per_page
|
||||
visible
|
||||
guardian
|
||||
no_definitions)
|
||||
end
|
||||
|
||||
|
@ -90,7 +91,7 @@ class TopicQuery
|
|||
options.assert_valid_keys(TopicQuery.valid_options)
|
||||
@options = options.dup
|
||||
@user = user
|
||||
@guardian = Guardian.new(@user)
|
||||
@guardian = options[:guardian] || Guardian.new(@user)
|
||||
end
|
||||
|
||||
def joined_topic_user(list = nil)
|
||||
|
|
Loading…
Reference in New Issue
Block a user