diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2009-02-06 12:13:44 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2009-02-06 12:13:44 +0100 |
commit | 7a5da7ce785616d79843dfebbb5107be8b46f8c5 (patch) | |
tree | 355145e59fbf166b8f2cde23dc8a13b188384c7e /actionpack/lib/action_controller/session | |
parent | 81c7a5d48d972c9e3973b4c018fafae1dfd9c0de (diff) | |
parent | be098f840614bbb71fe26f0e2b4c064b6866c076 (diff) | |
download | rails-7a5da7ce785616d79843dfebbb5107be8b46f8c5.tar.gz rails-7a5da7ce785616d79843dfebbb5107be8b46f8c5.tar.bz2 rails-7a5da7ce785616d79843dfebbb5107be8b46f8c5.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/lib/action_controller/session')
-rw-r--r-- | actionpack/lib/action_controller/session/abstract_store.rb | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/session/abstract_store.rb b/actionpack/lib/action_controller/session/abstract_store.rb index 9434c2e05e..41a35f867f 100644 --- a/actionpack/lib/action_controller/session/abstract_store.rb +++ b/actionpack/lib/action_controller/session/abstract_store.rb @@ -58,9 +58,28 @@ module ActionController end def load! - @id, session = @by.send(:load_session, @env) - replace(session) - @loaded = true + stale_session_check! do + @id, session = @by.send(:load_session, @env) + replace(session) + @loaded = true + end + end + + def stale_session_check! + yield + rescue ArgumentError => argument_error + if argument_error.message =~ %r{undefined class/module ([\w:]*\w)} + begin + # Note that the regexp does not allow $1 to end with a ':' + $1.constantize + rescue LoadError, NameError => const_error + raise ActionController::SessionRestoreError, "Session contains objects whose class definition isn\\'t available.\nRemember to require the classes for all objects kept in the session.\n(Original exception: \#{const_error.message} [\#{const_error.class}])\n" + end + + retry + else + raise + end end end |