aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/request
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-02-26 03:06:38 +1030
committerMatthew Draper <matthew@trebex.net>2016-02-26 03:06:38 +1030
commit6216a092ccfe6422f113db906a52fe8ffdafdbe6 (patch)
tree7f6fe35ff8f02185aeb9f2c8184665eb44bda81f /actionpack/lib/action_dispatch/request
parent1f8ce32edcce503490aa873dd49788c6fd79c135 (diff)
downloadrails-6216a092ccfe6422f113db906a52fe8ffdafdbe6.tar.gz
rails-6216a092ccfe6422f113db906a52fe8ffdafdbe6.tar.bz2
rails-6216a092ccfe6422f113db906a52fe8ffdafdbe6.zip
Revert "Update Session to utilize indiffernt access"
This reverts commit 45a75a3fcc96b22954caf69be2df4e302b134d7a. HWIAs are better than silently deeply-stringified hashes... but that's a reaction to a shortcoming of one particular session store: we should not break the basic behaviour of other, more featureful, session stores in the process. Fixes #23884
Diffstat (limited to 'actionpack/lib/action_dispatch/request')
-rw-r--r--actionpack/lib/action_dispatch/request/session.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/request/session.rb b/actionpack/lib/action_dispatch/request/session.rb
index 38d0da3e67..f6428af636 100644
--- a/actionpack/lib/action_dispatch/request/session.rb
+++ b/actionpack/lib/action_dispatch/request/session.rb
@@ -88,13 +88,13 @@ module ActionDispatch
# nil if the given key is not found in the session.
def [](key)
load_for_read!
- @delegate[key]
+ @delegate[key.to_s]
end
# Returns true if the session has the given key or false.
def has_key?(key)
load_for_read!
- @delegate.key?(key)
+ @delegate.key?(key.to_s)
end
alias :key? :has_key?
alias :include? :has_key?
@@ -112,7 +112,7 @@ module ActionDispatch
# Writes given value to given key of the session.
def []=(key, value)
load_for_write!
- @delegate[key] = value
+ @delegate[key.to_s] = value
end
# Clears the session.
@@ -139,13 +139,13 @@ module ActionDispatch
# # => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}
def update(hash)
load_for_write!
- @delegate.update hash
+ @delegate.update stringify_keys(hash)
end
# Deletes given key from the session.
def delete(key)
load_for_write!
- @delegate.delete key
+ @delegate.delete key.to_s
end
# Returns value of the given key from the session, or raises +KeyError+
@@ -165,9 +165,9 @@ module ActionDispatch
def fetch(key, default=Unspecified, &block)
load_for_read!
if default == Unspecified
- @delegate.fetch(key, &block)
+ @delegate.fetch(key.to_s, &block)
else
- @delegate.fetch(key, default, &block)
+ @delegate.fetch(key.to_s, default, &block)
end
end
@@ -211,9 +211,15 @@ module ActionDispatch
def load!
id, session = @by.load_session @req
options[:id] = id
- @delegate.replace(session)
+ @delegate.replace(stringify_keys(session))
@loaded = true
end
+
+ def stringify_keys(other)
+ other.each_with_object({}) { |(key, value), hash|
+ hash[key.to_s] = value
+ }
+ end
end
end
end