DEV: better log around nil client_settings_json (#27868)

Internal ref t/132507
This commit is contained in:
Régis Hanol 2024-07-11 11:30:53 +02:00 committed by GitHub
parent 374279b93e
commit 8fe73ab404
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 19 deletions

View File

@ -154,33 +154,36 @@ module SiteSettingExtension
end
def client_settings_json
Discourse
.cache
.fetch(SiteSettingExtension.client_settings_cache_key, expires_in: 30.minutes) do
client_settings_json_uncached
end
key = SiteSettingExtension.client_settings_cache_key
json = Discourse.cache.fetch(key, expires_in: 30.minutes) { client_settings_json_uncached }
Rails.logger.error("Nil client_settings_json from the cache for '#{key}'") if json.nil?
json || ""
rescue => e
Rails.logger.error("Error while retrieving client_settings_json: #{e.message}")
""
end
def client_settings_json_uncached
MultiJson.dump(
Hash[
*@client_settings
.map do |name|
value =
if deprecated_settings.include?(name.to_s)
public_send(name, warn: false)
else
public_send(name)
end
type = type_supervisor.get_type(name)
value = value.to_s if type == :upload
value = value.map(&:to_s).join("|") if type == :uploaded_image_list
*@client_settings.flat_map do |name|
value =
if deprecated_settings.include?(name.to_s)
public_send(name, warn: false)
else
public_send(name)
end
type = type_supervisor.get_type(name)
value = value.to_s if type == :upload
value = value.map(&:to_s).join("|") if type == :uploaded_image_list
[name, value]
end
.flatten
[name, value]
end
],
)
rescue => e
Rails.logger.error("Error while generating client_settings_json_uncached: #{e.message}")
nil
end
# Retrieve all settings