summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDJ Mountney <david@twkie.net>2016-05-27 14:28:04 -0700
committerDJ Mountney <david@twkie.net>2016-05-27 14:28:04 -0700
commit78d8458773f9538ae75f3c0074c6903ff1b5ec06 (patch)
treeaa6d294df8a7d8a91249021d2873262f81edb948 /lib
parentf9bb9151b595fdc1afc1742bb51c816965908f53 (diff)
downloadgitlab-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.rb22
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