diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-07-07 13:44:16 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-07-07 13:44:16 -0300 |
commit | 09f6fe1cd4099837c5801fe654804ae058c211b4 (patch) | |
tree | da14b61b5048406d6dd83ed5b23d7ff539fbec3c /actionview/lib | |
parent | a67cc28311b0ecb4282ca7d80b5ece959d22628f (diff) | |
download | rails-09f6fe1cd4099837c5801fe654804ae058c211b4.tar.gz rails-09f6fe1cd4099837c5801fe654804ae058c211b4.tar.bz2 rails-09f6fe1cd4099837c5801fe654804ae058c211b4.zip |
Fix "Stack Level Too Deep" error when rendering recursive partials
When rendering recursive partial Action View is trying to generate the
view digest infinitly causing a stack level error.
Fixes #11340
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/digestor.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb index 9324a1ac50..a674e4d7ea 100644 --- a/actionview/lib/action_view/digestor.rb +++ b/actionview/lib/action_view/digestor.rb @@ -7,10 +7,14 @@ module ActionView @@cache = ThreadSafe::Cache.new def self.digest(name, format, finder, options = {}) - cache_key = [name, format] + Array.wrap(options[:dependencies]) - @@cache[cache_key.join('.')] ||= begin + cache_key = ([name, format] + Array.wrap(options[:dependencies])).join('.') + @@cache.fetch(cache_key) do + @@cache[cache_key] ||= nil if options[:partial] # Prevent re-entry + klass = options[:partial] || name.include?("/_") ? PartialDigestor : Digestor - klass.new(name, format, finder, options).digest + digest = klass.new(name, format, finder, options).digest + + @@cache[cache_key] = digest # Store the value end end |