diff --git a/lib/discourse.rb b/lib/discourse.rb index dc17e18f9c9..c6280786eb2 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -606,15 +606,18 @@ module Discourse if SiteSetting.tos_url.present? SiteSetting.tos_url else - urls_cache["tos"] ||= ( + return urls_cache["tos"] if urls_cache["tos"].present? + + tos_url = if SiteSetting.tos_topic_id > 0 && Topic.exists?(id: SiteSetting.tos_topic_id) "#{Discourse.base_path}/tos" - else - :nil end - ) - urls_cache["tos"] != :nil ? urls_cache["tos"] : nil + if tos_url + urls_cache["tos"] = tos_url + else + urls_cache.delete("tos") + end end end @@ -622,15 +625,18 @@ module Discourse if SiteSetting.privacy_policy_url.present? SiteSetting.privacy_policy_url else - urls_cache["privacy_policy"] ||= ( + return urls_cache["privacy_policy"] if urls_cache["privacy_policy"].present? + + privacy_policy_url = if SiteSetting.privacy_topic_id > 0 && Topic.exists?(id: SiteSetting.privacy_topic_id) "#{Discourse.base_path}/privacy" - else - :nil end - ) - urls_cache["privacy_policy"] != :nil ? urls_cache["privacy_policy"] : nil + if privacy_policy_url + urls_cache["privacy_policy"] = privacy_policy_url + else + urls_cache.delete("privacy_policy") + end end end