]> git.openstreetmap.org Git - rails.git/commitdiff
Cope with sessions which don't exist.
authorTom Hughes <tom@compton.nu>
Tue, 28 Apr 2009 12:08:47 +0000 (12:08 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 28 Apr 2009 12:08:47 +0000 (12:08 +0000)
vendor/plugins/sql_session_store/lib/postgresql_session.rb

index 60046833a2bf2e657be83f1e17b5121596b970b8..53dc04c73cee359363e029c44415a913a6b8de2d 100755 (executable)
@@ -46,8 +46,12 @@ class PostgresqlSession
     def find_session(session_id)
       connection = session_connection
       result = connection.query("SELECT id, data FROM sessions WHERE session_id = $1 LIMIT 1", [session_id])
-      my_session = new(session_id, result.getvalue(0, 1))
-      my_session.id = result.getvalue(0, 0)
+      if result.ntuples > 0
+        my_session = new(session_id, result.getvalue(0, 1))
+        my_session.id = result.getvalue(0, 0)
+      else
+        my_session = nil
+      end
       result.clear
       my_session
     end