diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-09-20 15:40:15 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-09-24 12:11:27 -0700 |
commit | a54a5d9f39df505fe7c68e14c693553bd29bd725 (patch) | |
tree | e742f1ddda1caec321b3048032a011c70b784eaf /app | |
parent | 22bf3848ef0e59fb7689bfeab3ba0d8079f1597e (diff) | |
download | gitlab-ce-a54a5d9f39df505fe7c68e14c693553bd29bd725.tar.gz |
Use `Gitlab::SafeRequestStore` in more places
Even if it doesn’t save lines of code, since people will tend to use
code they’ve seen. And `SafeRequestStore` is safer since you
don’t have to remember to check `RequestStore.active?`.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ability.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/bulk_member_access_load.rb | 6 | ||||
-rw-r--r-- | app/models/namespace.rb | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index a853106e5bd..1466407d0d1 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -74,7 +74,7 @@ class Ability end def policy_for(user, subject = :global) - cache = RequestStore.active? ? RequestStore : {} + cache = Gitlab::SafeRequestStore.active? ? Gitlab::SafeRequestStore : {} DeclarativePolicy.policy_for(user, subject, cache: cache) end diff --git a/app/models/concerns/bulk_member_access_load.rb b/app/models/concerns/bulk_member_access_load.rb index c4346d5dd17..041ed3755e0 100644 --- a/app/models/concerns/bulk_member_access_load.rb +++ b/app/models/concerns/bulk_member_access_load.rb @@ -16,9 +16,9 @@ module BulkMemberAccessLoad key = max_member_access_for_resource_key(resource_klass, memoization_index) access = {} - if RequestStore.active? - RequestStore.store[key] ||= {} - access = RequestStore.store[key] + if Gitlab::SafeRequestStore.active? + Gitlab::SafeRequestStore[key] ||= {} + access = Gitlab::SafeRequestStore[key] end # Look up only the IDs we need diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 0289f29211d..c54be778d1b 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -148,8 +148,8 @@ class Namespace < ActiveRecord::Base def find_fork_of(project) return nil unless project.fork_network - if RequestStore.active? - forks_in_namespace = RequestStore.fetch("namespaces:#{id}:forked_projects") do + if Gitlab::SafeRequestStore.active? + forks_in_namespace = Gitlab::SafeRequestStore.fetch("namespaces:#{id}:forked_projects") do Hash.new do |found_forks, project| found_forks[project] = project.fork_network.find_forks_in(projects).first end |