mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: allowed_theme_ids should not be persisted in GlobalSettings (#14756)
* FIX: allowed_theme_ids should not be persisted in GlobalSettings It was observed that the memoized value of `GlobalSetting.allowed_theme_ids` would be persisted across requests, which could lead to unpredictable/undesired behaviours in a multisite environment. This change moves that logic out of GlobalSettings so that the returned theme IDs are correct for the current site. Uses get_set_cache, which ultimately uses DistributedCache, which will take care of multisite issues for us.
This commit is contained in:
@@ -183,6 +183,18 @@ class Theme < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def self.allowed_remote_theme_ids
|
||||
return nil if GlobalSetting.allowed_theme_repos.blank?
|
||||
|
||||
get_set_cache "allowed_remote_theme_ids" do
|
||||
urls = GlobalSetting.allowed_theme_repos.split(",").map(&:strip)
|
||||
Theme
|
||||
.joins(:remote_theme)
|
||||
.where('remote_themes.remote_url in (?)', urls)
|
||||
.pluck(:id)
|
||||
end
|
||||
end
|
||||
|
||||
def self.components_for(theme_id)
|
||||
get_set_cache "theme_components_for_#{theme_id}" do
|
||||
ChildTheme.where(parent_theme_id: theme_id).pluck(:child_theme_id)
|
||||
|
||||
Reference in New Issue
Block a user