1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Calling exists? in the session store, without checking for stale sessions, was causing the cookie store to panic because we need to unpack the whole session to get its key. This commit fixes this issue and also caches exists calls for performance improvements.

This commit is contained in:
José Valim 2010-06-25 12:14:59 +02:00
parent 518b16d9ae
commit 21c99e9388
2 changed files with 10 additions and 10 deletions

View file

@ -88,7 +88,10 @@ module ActionDispatch
end
def exists?
@by.send(:exists?, @env)
return @exists if instance_variable_defined?(:@exists)
stale_session_check! do
@exists = @by.send(:exists?, @env)
end
end
def loaded?

View file

@ -62,11 +62,12 @@ module ActionDispatch
end
def unpacked_cookie_data(env)
request = ActionDispatch::Request.new(env)
if data = request.cookie_jar.signed[@key]
data.stringify_keys!
else
{}
env["action_dispatch.request.unsigned_session_cookie"] ||= begin
request = ActionDispatch::Request.new(env)
if data = request.cookie_jar.signed[@key]
data.stringify_keys!
end
data || {}
end
end
@ -78,10 +79,6 @@ module ActionDispatch
persistent_session_id!(session_data, sid)
end
def exists?(env)
ActionDispatch::Request.new(env).cookie_jar.key?(@key)
end
def destroy(env)
# session data is stored on client; nothing to do here
end