mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:03:22 +08:00
DEV: Make multisite freedom patch compatible with Rails 7.1+
This commit is contained in:
parent
5f1e182956
commit
7610553c82
17
Gemfile.lock
17
Gemfile.lock
|
@ -336,15 +336,16 @@ GEM
|
|||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.5.0)
|
||||
loofah (~> 2.19, >= 2.19.1)
|
||||
rails_failover (1.0.0)
|
||||
activerecord (> 6.0, < 7.1)
|
||||
rails-html-sanitizer (1.6.0)
|
||||
loofah (~> 2.21)
|
||||
nokogiri (~> 1.14)
|
||||
rails_failover (2.0.1)
|
||||
activerecord (>= 6.1, <= 7.1)
|
||||
concurrent-ruby
|
||||
railties (> 6.0, < 7.1)
|
||||
rails_multisite (4.0.1)
|
||||
activerecord (> 5.0, < 7.1)
|
||||
railties (> 5.0, < 7.1)
|
||||
railties (>= 6.1, <= 7.1)
|
||||
rails_multisite (5.0.0)
|
||||
activerecord (>= 6.0)
|
||||
railties (>= 6.0)
|
||||
railties (7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
|
|
|
@ -94,7 +94,6 @@ module Discourse
|
|||
config.active_record.cache_versioning = false # our custom cache class doesn’t support this
|
||||
config.action_controller.forgery_protection_origin_check = false
|
||||
config.active_record.belongs_to_required_by_default = false
|
||||
config.active_record.legacy_connection_handling = true
|
||||
config.active_record.yaml_column_permitted_classes = [
|
||||
Hash,
|
||||
HashWithIndifferentAccess,
|
||||
|
|
|
@ -12,18 +12,17 @@ module RailsMultisite
|
|||
|
||||
reading_role = :"#{db}_#{ActiveRecord.reading_role}"
|
||||
spec = RailsMultisite::ConnectionManagement.connection_spec(db: db)
|
||||
handler = ActiveRecord::Base.connection_handler
|
||||
|
||||
ActiveRecord::Base.connection_handlers[reading_role] ||= begin
|
||||
handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
|
||||
RailsFailover::ActiveRecord.establish_reading_connection(handler, spec)
|
||||
handler
|
||||
end
|
||||
|
||||
RailsFailover::ActiveRecord.establish_reading_connection(
|
||||
handler,
|
||||
spec.to_hash,
|
||||
role: reading_role,
|
||||
)
|
||||
ActiveRecord::Base.connected_to(role: reading_role) { yield(db) if block_given? }
|
||||
rescue => e
|
||||
STDERR.puts "URGENT: Failed to initialize site #{db}: " \
|
||||
"#{e.class} #{e.message}\n#{e.backtrace.join("\n")}"
|
||||
|
||||
# the show must go on, don't stop startup if multisite fails
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user