FIX: Cache `Discourse.system_user` separately for each multisite tenant (#8276)
This was not causing any known issue, because the system user ID is always the same across all sites. However, we should cache this on a per-site basis to be safe.
This commit is contained in:
parent
15b25547bb
commit
1f88ecf6d8
|
@ -536,7 +536,9 @@ module Discourse
|
||||||
SYSTEM_USER_ID ||= -1
|
SYSTEM_USER_ID ||= -1
|
||||||
|
|
||||||
def self.system_user
|
def 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)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.store
|
def self.store
|
||||||
|
|
|
@ -130,6 +130,12 @@ describe Discourse do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context '#system_user' do
|
||||||
|
it 'returns the system user' do
|
||||||
|
expect(Discourse.system_user.id).to eq(-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "#store" do
|
context "#store" do
|
||||||
|
|
||||||
it "returns LocalStore by default" do
|
it "returns LocalStore by default" do
|
||||||
|
|
Loading…
Reference in New Issue