mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 02:41:13 +08:00
DEV: Add a helper method to clear every possible theme cache (#17585)
Our theme system is very complex and it can take a while to figure out how to invalidate the various types of caches that are used throughout the theme system. So, having a single helper method that invalidates everything can be useful in emergency situations where there is no time to read through the code and figure out how to clear the various caches. Internal ticket: t64732.
This commit is contained in:
@ -1028,4 +1028,14 @@ module Discourse
|
||||
def self.allow_dev_populate?
|
||||
Rails.env.development? || ENV["ALLOW_DEV_POPULATE"] == "1"
|
||||
end
|
||||
|
||||
# warning: this method is very expensive and shouldn't be called in places
|
||||
# where performance matters. it's meant to be called manually (e.g. in the
|
||||
# rails console) when dealing with an emergency that requires invalidating
|
||||
# theme cache
|
||||
def self.clear_all_theme_cache!
|
||||
ThemeField.force_recompilation!
|
||||
Theme.all.each(&:update_javascript_cache!)
|
||||
Theme.expire_site_cache!
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user