mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FIX: Clear anon cache when disabling readonly mode.
`SiteSerializer#is_readonly` is cached for an anonymous user so we have to clear the cache when disabling readonly mode. Otherwise, the site may appear to be in readonly mode for an extended period of time.
This commit is contained in:
parent
9e795b9d90
commit
c0aae16f6b
@ -125,10 +125,12 @@ class Site
|
||||
json
|
||||
end
|
||||
|
||||
SITE_JSON_CHANNEL = '/site_json'
|
||||
|
||||
def self.clear_anon_cache!
|
||||
# publishing forces the sequence up
|
||||
# the cache is validated based on the sequence
|
||||
MessageBus.publish('/site_json', '')
|
||||
MessageBus.publish(SITE_JSON_CHANNEL, '')
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -346,6 +346,7 @@ module Discourse
|
||||
def self.disable_readonly_mode(key = READONLY_MODE_KEY)
|
||||
$redis.del(key)
|
||||
MessageBus.publish(readonly_channel, false)
|
||||
Site.clear_anon_cache!
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -190,11 +190,17 @@ describe Discourse do
|
||||
describe ".disable_readonly_mode" do
|
||||
it "removes a key from redis and publish a message through the message bus" do
|
||||
Discourse.enable_readonly_mode
|
||||
message = nil
|
||||
|
||||
message = get_readonly_message do
|
||||
messages = MessageBus.track_publish do
|
||||
Discourse.disable_readonly_mode
|
||||
end
|
||||
|
||||
expect(messages.any? { |m| m.channel == Site::SITE_JSON_CHANNEL })
|
||||
.to eq(true)
|
||||
|
||||
message = messages.find { |m| m.channel == Discourse.readonly_channel }
|
||||
|
||||
assert_readonly_mode_disabled(message, readonly_mode_key)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user