diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-06-05 15:10:20 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-06-05 16:05:55 -0300 |
commit | 3cba6eee66a4c25b93839ea6fd1da08d7780f2de (patch) | |
tree | 737150e38db6b8d3e683e944cb24f89d46a33207 /actionpack/lib/action_dispatch | |
parent | f7cde3eb2231f31764739a9abdf2610dd2721fe8 (diff) | |
download | rails-3cba6eee66a4c25b93839ea6fd1da08d7780f2de.tar.gz rails-3cba6eee66a4c25b93839ea6fd1da08d7780f2de.tar.bz2 rails-3cba6eee66a4c25b93839ea6fd1da08d7780f2de.zip |
Revert "fix the Flash middleware loading the session on every request (very dangerous especially with Rack::Cache), it should only be loaded when the flash method is called"
This reverts commits e3069c64b2c5ddc7a5789b55b8efd4902d9e9729 and 2b2983d76fd11efc219273036a612f47cfaa5bfa.
Reason: This add a non-backward compatible change in the way that flash
works now (swept in every request).
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/flash.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index 6f97c06b6b..bc5b163931 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -4,7 +4,7 @@ module ActionDispatch # read a notice you put there or <tt>flash["notice"] = "hello"</tt> # to put a new one. def flash - @env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new).tap(&:sweep) + @env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new) end end @@ -235,6 +235,10 @@ module ActionDispatch end def call(env) + if (session = env['rack.session']) && (flash = session['flash']) + flash.sweep + end + @app.call(env) ensure session = env['rack.session'] || {} @@ -251,8 +255,7 @@ module ActionDispatch env[KEY] = new_hash end - if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?) - session.key?('flash') && session['flash'].empty? + if session.key?('flash') && session['flash'].empty? session.delete('flash') end end |