mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
FIX: deprecation warning - initialization autoloaded the constant (#12400)
Get rid of deprecation related to Zeitwerk autoloader. Original PR was reverted because of multisite bug #12381 - thank you @davidtaylorhq for fixing it. I added the last commit to fix that multisite problem.
This commit is contained in:
parent
ddf8e9b6b6
commit
e10a74694a
@ -55,6 +55,8 @@ require 'pry-rails' if Rails.env.development?
|
||||
|
||||
require 'discourse_fonts'
|
||||
|
||||
require_relative '../lib/zeitwerk_config.rb'
|
||||
|
||||
if defined?(Bundler)
|
||||
bundler_groups = [:default]
|
||||
|
||||
@ -116,6 +118,7 @@ module Discourse
|
||||
config.autoload_paths += Dir["#{config.root}/lib/validators/"]
|
||||
|
||||
Rails.autoloaders.main.ignore(Dir["#{config.root}/app/models/reports"])
|
||||
Rails.autoloaders.main.ignore(Dir["#{config.root}/lib/freedom_patches"])
|
||||
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||
|
@ -1,5 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Multisite freedom patch defines RailsMultisite::DiscoursePatches.config which is used by 200-first_middlewares.rb
|
||||
# Therefore it can not be postponed with .to_prepare
|
||||
RUN_WITHOUT_PREPARE = ["#{Rails.root}/lib/freedom_patches/rails_multisite.rb"]
|
||||
RUN_WITHOUT_PREPARE.each { |path| require(path) }
|
||||
|
||||
Rails.application.reloader.to_prepare do
|
||||
Dir["#{Rails.root}/lib/freedom_patches/*.rb"].each do |f|
|
||||
next if RUN_WITHOUT_PREPARE.any? { |path| path == f }
|
||||
require(f)
|
||||
end
|
||||
end
|
||||
|
@ -16,6 +16,7 @@ if GlobalSetting.skip_redis?
|
||||
return
|
||||
end
|
||||
|
||||
Rails.application.reloader.to_prepare do
|
||||
reload_settings = lambda {
|
||||
RailsMultisite::ConnectionManagement.safe_each_connection do
|
||||
begin
|
||||
@ -37,3 +38,4 @@ if !Rails.configuration.cache_classes
|
||||
reload_settings.call
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,6 +5,7 @@
|
||||
require 'i18n/backend/discourse_i18n'
|
||||
require 'i18n/backend/fallback_locale_list'
|
||||
|
||||
Rails.application.reloader.to_prepare do
|
||||
I18n.backend = I18n::Backend::DiscourseI18n.new
|
||||
I18n.fallbacks = I18n::Backend::FallbackLocaleList.new
|
||||
I18n.config.missing_interpolation_argument_handler = proc { throw(:exception) }
|
||||
@ -17,3 +18,4 @@ unless Rails.env.test?
|
||||
ExtraLocalesController.clear_cache!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,12 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if GlobalSetting.skip_redis?
|
||||
Rails.application.reloader.to_prepare do
|
||||
if Rails.logger.respond_to? :chained
|
||||
Rails.logger = Rails.logger.chained.first
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
Rails.application.reloader.to_prepare do
|
||||
if Rails.env.development? && RUBY_VERSION.match?(/^2\.5\.[23]/)
|
||||
STDERR.puts "WARNING: Discourse development environment runs slower on Ruby 2.5.3 or below"
|
||||
STDERR.puts "We recommend you upgrade to Ruby 2.6.1 for the optimal development performance"
|
||||
@ -146,3 +149,4 @@ Discourse.plugins.each do |plugin|
|
||||
url: plugin.metadata.url
|
||||
}
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user