Skip to content

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

PERF: avoid filtering shared drafts when not used

Sam Saffron0d5d47814668
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index cbb76449828..51d60f5c137 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -591,6 +591,11 @@ class TopicQuery
end
def apply_shared_drafts(result, category_id, options)
+
+ # PERF: avoid any penalty if there are no shared drafts enabled
+ # on some sites the cost can be high eg: gearbox
+ return result if SiteSetting.shared_drafts_category == ""
+
drafts_category_id = SiteSetting.shared_drafts_category.to_i
viewing_shared = category_id && category_id == drafts_category_id
can_create_shared = guardian.can_create_shared_draft?