FIX: Invalidate site settings cache in all instances (#16155)
Previous cache implementation did not support multisite instances and the cache was invalidated only in the instance where the change took place.
This commit is contained in:
parent
94750c81fa
commit
7a416257df
|
@ -101,23 +101,33 @@ class SiteSetting < ActiveRecord::Base
|
|||
:markdown_typographer_quotation_marks
|
||||
]
|
||||
|
||||
def self.reset_cached_settings!
|
||||
@blocked_attachment_content_types_regex = nil
|
||||
@blocked_attachment_filenames_regex = nil
|
||||
@allowed_unicode_username_regex = nil
|
||||
end
|
||||
|
||||
def self.blocked_attachment_content_types_regex
|
||||
@blocked_attachment_content_types_regex ||= Regexp.union(SiteSetting.blocked_attachment_content_types.split("|"))
|
||||
current_db = RailsMultisite::ConnectionManagement.current_db
|
||||
|
||||
@blocked_attachment_content_types_regex ||= {}
|
||||
@blocked_attachment_content_types_regex[current_db] ||= begin
|
||||
Regexp.union(SiteSetting.blocked_attachment_content_types.split("|"))
|
||||
end
|
||||
end
|
||||
|
||||
def self.blocked_attachment_filenames_regex
|
||||
@blocked_attachment_filenames_regex ||= Regexp.union(SiteSetting.blocked_attachment_filenames.split("|"))
|
||||
current_db = RailsMultisite::ConnectionManagement.current_db
|
||||
|
||||
@blocked_attachment_filenames_regex ||= {}
|
||||
@blocked_attachment_filenames_regex[current_db] ||= begin
|
||||
Regexp.union(SiteSetting.blocked_attachment_filenames.split("|"))
|
||||
end
|
||||
end
|
||||
|
||||
def self.allowed_unicode_username_characters_regex
|
||||
@allowed_unicode_username_regex ||= SiteSetting.allowed_unicode_username_characters.present? \
|
||||
? Regexp.new(SiteSetting.allowed_unicode_username_characters) : nil
|
||||
current_db = RailsMultisite::ConnectionManagement.current_db
|
||||
|
||||
@allowed_unicode_username_regex ||= {}
|
||||
@allowed_unicode_username_regex[current_db] ||= begin
|
||||
if SiteSetting.allowed_unicode_username_characters.present?
|
||||
Regexp.new(SiteSetting.allowed_unicode_username_characters)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# helpers for getting s3 settings that fallback to global
|
||||
|
@ -246,6 +256,16 @@ class SiteSetting < ActiveRecord::Base
|
|||
send("#{new_method}=", args)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def self.clear_cache!
|
||||
super
|
||||
|
||||
@blocked_attachment_content_types_regex = nil
|
||||
@blocked_attachment_filenames_regex = nil
|
||||
@allowed_unicode_username_regex = nil
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
|
|
@ -45,10 +45,6 @@ DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|
|
|||
SiteIconManager.ensure_optimized!
|
||||
end
|
||||
|
||||
if SiteSetting::WATCHED_SETTINGS.include?(name)
|
||||
SiteSetting.reset_cached_settings!
|
||||
end
|
||||
|
||||
# Make sure medium and high priority thresholds were calculated.
|
||||
if name == :reviewable_low_priority_threshold && Reviewable.min_score_for_priority(:medium) > 0
|
||||
Reviewable.set_priorities(low: new_value)
|
||||
|
|
Loading…
Reference in New Issue