Commits

Anonymous committed 63fa855

0.12.3dev: Fixed purging of anonymous sessions to actually purge session attributes as well.

Closes #10170.

  • Participants
  • Parent commits b08b6ad
  • Branches 0.12-stable

Comments (0)

Files changed (2)

trac/web/session.py

             cursor.execute("""
                 DELETE FROM session_attribute
                 WHERE authenticated=0
-                      AND sid IN (SELECT sid FROM session
-                                  WHERE authenticated=0 AND last_visit<%s)
-                """, (ts,))
+                      AND sid NOT IN (SELECT sid FROM session
+                                      WHERE authenticated=0)
+                """)

trac/web/tests/session.py

         sess_admin._do_purge('2010-01-02')
         result = [i for i in sess_admin._get_list(['*'])]
         self.assertEqual(result, auth_list + anon_list)
+        result = get_session_info(self.db, anon_list[0][0])
+        self.assertEqual(result, ('name10', 'val10', 'val10'))
+        result = get_session_info(self.db, anon_list[1][0])
+        self.assertEqual(result, ('name11', 'val11', 'val11'))
 
         auth_list, anon_list, all_list = \
             _prep_session_table(self.db, spread_visits=True)
         sess_admin._do_purge('2010-01-12')
         result = [i for i in sess_admin._get_list(['*'])]
         self.assertEqual(result, auth_list + anon_list[1:])
+        cursor = self.db.cursor()
+        cursor.execute("""
+            SELECT name, value FROM session_attribute WHERE sid = %s
+            """, (anon_list[0][0],))
+        self.assertEqual([], list(cursor))
+        result = get_session_info(self.db, anon_list[1][0])
+        self.assertEqual(result, ('name11', 'val11', 'val11'))
 
 
 def suite():