DEV: Make banner cache work like other caches (#20811)

This commit is contained in:
Daniel Waterworth 2023-03-24 12:36:55 -05:00 committed by GitHub
parent 88004873ec
commit 7e23e6c1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 8 deletions

View File

@ -686,16 +686,15 @@ class ApplicationController < ActionController::Base
end
def banner_json
json = ApplicationController.banner_json_cache["json"]
return "{}" if !current_user && SiteSetting.login_required?
unless json
topic = Topic.where(archetype: Archetype.banner).first
banner = topic.present? ? topic.banner : {}
ApplicationController.banner_json_cache["json"] = json = MultiJson.dump(banner)
end
json
ApplicationController
.banner_json_cache
.defer_get_set("json") do
topic = Topic.where(archetype: Archetype.banner).first
banner = topic.present? ? topic.banner : {}
MultiJson.dump(banner)
end
end
def custom_emoji