FIX: Fix rake db:create after zeitwerk changes

FIX: Fix rake db:create after zeitwerk changes

Post-zeitwerk, rails has deprecated autoloading modules during initialization and forces all autoloaded modules to be reloaded after initialization.

Requiring the file explicitly prevents autoloading and therefore prevents the state on SiteSetting being trashed which was causing the problem here.

diff --git a/config/initializers/005-site_settings.rb b/config/initializers/005-site_settings.rb
index 7f44704..4ecaa85 100644
--- a/config/initializers/005-site_settings.rb
+++ b/config/initializers/005-site_settings.rb
@@ -6,6 +6,10 @@
 Discourse.git_version
 
 if GlobalSetting.skip_redis?
+  # Requiring this file explicitly prevents it from being autoloaded and so the
+  # provider attribute is not cleared
+  require File.expand_path('../../../app/models/site_setting', __FILE__)
+
   require 'site_settings/local_process_provider'
   Rails.cache = Discourse.cache
   SiteSetting.provider = SiteSettings::LocalProcessProvider.new

GitHub sha: 4c9ed7bd

1 Like