Commit 7a2325e4 authored by Stan Hu's avatar Stan Hu

Guard against nested allows with ref name caching

This avoids the case:

```
allow_ref_name_caching do
  allow_ref_name_caching do
    # using-feature
  end
end
```
parent db759c5d
...@@ -781,7 +781,7 @@ module Ci ...@@ -781,7 +781,7 @@ module Ci
end end
def git_ref def git_ref
strong_memoize(:git_pref) do strong_memoize(:git_ref) do
if merge_request_event? if merge_request_event?
## ##
# In the future, we're going to change this ref to # In the future, we're going to change this ref to
......
...@@ -302,6 +302,7 @@ module Gitlab ...@@ -302,6 +302,7 @@ module Gitlab
# branch, this method allows caching of the ref name directly. # branch, this method allows caching of the ref name directly.
def self.allow_ref_name_caching def self.allow_ref_name_caching
return yield unless Gitlab::SafeRequestStore.active? return yield unless Gitlab::SafeRequestStore.active?
return yield if ref_name_caching_allowed?
begin begin
Gitlab::SafeRequestStore[:allow_ref_name_caching] = true Gitlab::SafeRequestStore[:allow_ref_name_caching] = true
......
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