diff options
author | DJ Mountney <david@twkie.net> | 2016-05-27 14:28:04 -0700 |
---|---|---|
committer | DJ Mountney <david@twkie.net> | 2016-05-27 14:28:04 -0700 |
commit | 78d8458773f9538ae75f3c0074c6903ff1b5ec06 (patch) | |
tree | aa6d294df8a7d8a91249021d2873262f81edb948 /lib | |
parent | f9bb9151b595fdc1afc1742bb51c816965908f53 (diff) | |
download | gitlab-ce-78d8458773f9538ae75f3c0074c6903ff1b5ec06.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/current_settings.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index f44d1b3a44e..59e86707d3e 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -1,18 +1,22 @@ module Gitlab module CurrentSettings def current_application_settings - key = :current_application_settings - - RequestStore.store[key] ||= begin - settings = nil + if RequestStore.active? + RequestStore.fetch(:current_application_settings) { ensure_application_settings! } + else + ensure_application_settings! + end + end - if connect_to_db? - settings = ::ApplicationSetting.current - settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration? - end + def ensure_application_settings! + settings = nil - settings || fake_application_settings + if connect_to_db? + settings = ::ApplicationSetting.current + settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration? end + + settings || fake_application_settings end def fake_application_settings |