don't cache context on feature flag

sometimes can't be marshalled

Change-Id: I10e7f2211272ecc575a0a805e7e8b271b984434d
Reviewed-on: https://gerrit.instructure.com/199499
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
James Williams 2019-06-28 07:31:36 -06:00
parent 16ddde6b26
commit 8241b4ebaf
1 changed files with 4 additions and 1 deletions

View File

@ -70,11 +70,14 @@ module FeatureFlags
# return the feature flag for the given feature that is defined on this object, if any.
# (helper method. use lookup_feature_flag to test policy.)
def feature_flag(feature)
return nil unless self.id
RequestCache.cache("feature_flag", self, feature) do
self.shard.activate do
result = feature_flag_cache.fetch(feature_flag_cache_key(feature)) do
self.feature_flags.where(feature: feature.to_s).first
# keep have the context association unloaded in case we can't marshal it
FeatureFlag.where(feature: feature.to_s).polymorphic_where(:context => self).first
end
result.context = self if result
result
end
end