FIX: Ensure UserField changes are reflected instantly in webhooks (#12291)

The Guardian object memoizes a list of allowed user fields. Normally this is fine because Guardian objects only persist for a single request. However, the WebHook class was memoizing a guardian at the class level. This meant that an app restart was required for changes to be reflected. Plus, the Guardian was being shared across all sites in a multisite instance.

Initializing a guardian is cheap, so we can manage without memoization here.
This commit is contained in:
David Taylor
2021-03-04 21:41:57 +00:00
committed by GitHub
parent 4af3c42904
commit 5a4d3e7576
2 changed files with 9 additions and 1 deletions

View File

@@ -110,7 +110,7 @@ class WebHook < ActiveRecord::Base
private
def self.guardian
@guardian ||= Guardian.new(Discourse.system_user)
Guardian.new(Discourse.system_user)
end
end