Why does the `SiteSettings` class use the `DistributedCache` without a `require 'distributed_cache';` statement?


(Discourse.PRO) #1

(Sam Saffron) #2

What particular issue is this causing?


(Discourse.PRO) #3

If I use require 'site_setting_extension' in my plugin, then I need to remember to add require 'distributed_cache' before.


(Sam Saffron) #4

The trouble is that now you are initializing site settings earlier than when the app does.

Can you post the exact code of what you are trying to achieve.


(Discourse.PRO) #5

I use SiteSettingExtension.module_eval in my plugins to add custom site setting types, e.g.:

require 'distributed_cache'
require 'site_setting_extension'
SiteSettingExtension.module_eval do
	alias_method :core__types, :types
	def types
		result = @types
		if not result
			result = core__types
			result[:paypal_buttons] = result.length + 1;
		end
		return result
	end
end