mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 20:16:19 +08:00
FIX: site settings loading default values when no db
This fixes a condition where an intermittent db connection could cause invalid site settings to be stored It also removes a catch all we had. Somewhere around Rails 5 `db:create` started wanting full environment this is a problem for Discourse since it needs to boot up data from the db. This removes the catch all and surgically adds a db / redis bypass to db:create task.
This commit is contained in:
parent
62f4284865
commit
3af00a65e6
|
@ -58,12 +58,7 @@ class SiteSettings::DbProvider
|
|||
# table is not in the db yet, initial migration, etc
|
||||
def table_exists?
|
||||
@table_exists ||= {}
|
||||
begin
|
||||
@table_exists[current_site] ||= ActiveRecord::Base.connection.table_exists?(@model.table_name)
|
||||
rescue
|
||||
STDERR.puts "No connection to db, unable to retrieve site settings! (normal when running db:create)"
|
||||
@table_exists[current_site] = false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -21,12 +21,23 @@ task 'db:environment:set' => [:load_config] do |_, args|
|
|||
end
|
||||
end
|
||||
|
||||
task 'db:create' => [:load_config] do |_, args|
|
||||
task 'db:force_skip_persist' do
|
||||
GlobalSetting.skip_db = true
|
||||
GlobalSetting.skip_redis = true
|
||||
end
|
||||
|
||||
task 'db:create' do |_, args|
|
||||
if MultisiteTestHelpers.load_multisite?
|
||||
system("RAILS_DB=discourse_test_multisite rake db:create")
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
reqs = Rake::Task['db:create'].prerequisites.map(&:to_sym)
|
||||
Rake::Task['db:create'].clear_prerequisites
|
||||
Rake::Task['db:create'].enhance(["db:force_skip_persist"] + reqs)
|
||||
end
|
||||
|
||||
task 'db:drop' => [:load_config] do |_, args|
|
||||
if MultisiteTestHelpers.load_multisite?
|
||||
system("RAILS_DB=discourse_test_multisite rake db:drop")
|
||||
|
|
Loading…
Reference in New Issue
Block a user