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)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
rails-html-sanitizer (1.5.0)
|
rails-html-sanitizer (1.6.0)
|
||||||
loofah (~> 2.19, >= 2.19.1)
|
loofah (~> 2.21)
|
||||||
rails_failover (1.0.0)
|
nokogiri (~> 1.14)
|
||||||
activerecord (> 6.0, < 7.1)
|
rails_failover (2.0.1)
|
||||||
|
activerecord (>= 6.1, <= 7.1)
|
||||||
concurrent-ruby
|
concurrent-ruby
|
||||||
railties (> 6.0, < 7.1)
|
railties (>= 6.1, <= 7.1)
|
||||||
rails_multisite (4.0.1)
|
rails_multisite (5.0.0)
|
||||||
activerecord (> 5.0, < 7.1)
|
activerecord (>= 6.0)
|
||||||
railties (> 5.0, < 7.1)
|
railties (>= 6.0)
|
||||||
railties (7.0.4.3)
|
railties (7.0.4.3)
|
||||||
actionpack (= 7.0.4.3)
|
actionpack (= 7.0.4.3)
|
||||||
activesupport (= 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.active_record.cache_versioning = false # our custom cache class doesn’t support this
|
||||||
config.action_controller.forgery_protection_origin_check = false
|
config.action_controller.forgery_protection_origin_check = false
|
||||||
config.active_record.belongs_to_required_by_default = false
|
config.active_record.belongs_to_required_by_default = false
|
||||||
config.active_record.legacy_connection_handling = true
|
|
||||||
config.active_record.yaml_column_permitted_classes = [
|
config.active_record.yaml_column_permitted_classes = [
|
||||||
Hash,
|
Hash,
|
||||||
HashWithIndifferentAccess,
|
HashWithIndifferentAccess,
|
||||||
|
|
|
@ -12,18 +12,17 @@ module RailsMultisite
|
||||||
|
|
||||||
reading_role = :"#{db}_#{ActiveRecord.reading_role}"
|
reading_role = :"#{db}_#{ActiveRecord.reading_role}"
|
||||||
spec = RailsMultisite::ConnectionManagement.connection_spec(db: db)
|
spec = RailsMultisite::ConnectionManagement.connection_spec(db: db)
|
||||||
|
handler = ActiveRecord::Base.connection_handler
|
||||||
|
|
||||||
ActiveRecord::Base.connection_handlers[reading_role] ||= begin
|
RailsFailover::ActiveRecord.establish_reading_connection(
|
||||||
handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
|
handler,
|
||||||
RailsFailover::ActiveRecord.establish_reading_connection(handler, spec)
|
spec.to_hash,
|
||||||
handler
|
role: reading_role,
|
||||||
end
|
)
|
||||||
|
|
||||||
ActiveRecord::Base.connected_to(role: reading_role) { yield(db) if block_given? }
|
ActiveRecord::Base.connected_to(role: reading_role) { yield(db) if block_given? }
|
||||||
rescue => e
|
rescue => e
|
||||||
STDERR.puts "URGENT: Failed to initialize site #{db}: " \
|
STDERR.puts "URGENT: Failed to initialize site #{db}: " \
|
||||||
"#{e.class} #{e.message}\n#{e.backtrace.join("\n")}"
|
"#{e.class} #{e.message}\n#{e.backtrace.join("\n")}"
|
||||||
|
|
||||||
# the show must go on, don't stop startup if multisite fails
|
# the show must go on, don't stop startup if multisite fails
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue