A platform for community discussion. Free, open, simple.
FIX: Cache `Discourse.system_user` separately for each multisite tenant (#8276)
David Taylor1f88ecf6d853
diff --git a/lib/discourse.rb b/lib/discourse.rbindex b7b65762fb1..561a4e979fa 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -536,7 +536,9 @@ module DiscourseSYSTEM_USER_ID ||= -1def self.system_user- @system_user ||= User.find_by(id: SYSTEM_USER_ID)+ @system_users ||= {}+ current_db = RailsMultisite::ConnectionManagement.current_db+ @system_users[current_db] ||= User.find_by(id: SYSTEM_USER_ID)enddef self.storediff --git a/spec/components/discourse_spec.rb b/spec/components/discourse_spec.rbindex 76a832c6d08..70559a5038d 100644--- a/spec/components/discourse_spec.rb+++ b/spec/components/discourse_spec.rb@@ -130,6 +130,12 @@ describe Discourse doend+ context '#system_user' do+ it 'returns the system user' do+ expect(Discourse.system_user.id).to eq(-1)+ end+ end+context "#store" doit "returns LocalStore by default" do