Commit 78d84587 authored by DJ Mountney's avatar DJ Mountney

Only use RequestStore for current_application_settings during a request

This fixes an issue where the RequestStore was being populated with the settings in the unicorn master
during the rails initializers. Each forked worker would then start their first request with an uncleaned RequestStore.
parent f9bb9151
module Gitlab module Gitlab
module CurrentSettings module CurrentSettings
def current_application_settings def current_application_settings
key = :current_application_settings if RequestStore.active?
RequestStore.fetch(:current_application_settings) { ensure_application_settings! }
RequestStore.store[key] ||= begin else
settings = nil ensure_application_settings!
end
end
if connect_to_db? def ensure_application_settings!
settings = ::ApplicationSetting.current settings = nil
settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
end
settings || fake_application_settings if connect_to_db?
settings = ::ApplicationSetting.current
settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
end end
settings || fake_application_settings
end end
def fake_application_settings def fake_application_settings
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment