mirror of
https://github.com/discourse/discourse.git
synced 2025-02-28 13:29:40 +08:00
FIX: Safety checks for categories index
This commit is contained in:
parent
b4544eb027
commit
33d0a6a876
@ -54,12 +54,14 @@ class CategoryList
|
|||||||
c.displayable_topics = []
|
c.displayable_topics = []
|
||||||
topics_in_cat.each do |topic_id|
|
topics_in_cat.each do |topic_id|
|
||||||
topic = @topics_by_id[topic_id]
|
topic = @topics_by_id[topic_id]
|
||||||
|
if topic.present?
|
||||||
topic.category = c
|
topic.category = c
|
||||||
c.displayable_topics << topic
|
c.displayable_topics << topic
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Add the uncategorized "magic" category
|
# Add the uncategorized "magic" category
|
||||||
def add_uncategorized
|
def add_uncategorized
|
||||||
@ -91,7 +93,7 @@ class CategoryList
|
|||||||
# Find the appropriate place to insert it:
|
# Find the appropriate place to insert it:
|
||||||
insert_at = nil
|
insert_at = nil
|
||||||
@categories.each_with_index do |c, idx|
|
@categories.each_with_index do |c, idx|
|
||||||
if uncategorized.topics_week > (c.topics_week || 0)
|
if (uncategorized.topics_week || 0) > (c.topics_week || 0)
|
||||||
insert_at = idx
|
insert_at = idx
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user