# HG changeset patch
# Parent 2fd35685f8d81b1cf7bfa69f44f10e212c88562e
web: avoid using a cursor after the connection from which it depends has been rollbacked (as this doesn't work with PySqlite due to some explicit close on rollback we do).
Closes #9104.
diff --git a/trac/web/session.py b/trac/web/session.py
|
a
|
b
|
class DetachedSession(dict): |
| 79 | 79 | authenticated = int(self.authenticated) |
| 80 | 80 | now = int(time.time()) |
| 81 | 81 | db = self.env.get_db_cnx() |
| 82 | | cursor = db.cursor() |
| 83 | 82 | |
| 84 | 83 | if self._new: |
| 85 | 84 | self.last_visit = now |
| … |
… |
class DetachedSession(dict): |
| 87 | 86 | # The session might already exist even if _new is True since |
| 88 | 87 | # it could have been created by a concurrent request (#3563). |
| 89 | 88 | try: |
| | 89 | cursor = db.cursor() |
| 90 | 90 | cursor.execute("INSERT INTO session (sid,last_visit,authenticated)" |
| 91 | 91 | " VALUES(%s,%s,%s)", |
| 92 | 92 | (self.sid, self.last_visit, authenticated)) |
| … |
… |
class DetachedSession(dict): |
| 96 | 96 | (self.sid, e)) |
| 97 | 97 | if self._old != self: |
| 98 | 98 | attrs = [(self.sid, authenticated, k, v) for k, v in self.items()] |
| | 99 | cursor = db.cursor() |
| 99 | 100 | cursor.execute("DELETE FROM session_attribute WHERE sid=%s", |
| 100 | 101 | (self.sid,)) |
| 101 | 102 | self._old = dict(self.items()) |
| … |
… |
class DetachedSession(dict): |
| 122 | 123 | if now - self.last_visit > UPDATE_INTERVAL: |
| 123 | 124 | self.last_visit = now |
| 124 | 125 | self.env.log.info("Refreshing session %s" % self.sid) |
| | 126 | cursor = db.cursor() |
| 125 | 127 | cursor.execute('UPDATE session SET last_visit=%s ' |
| 126 | 128 | 'WHERE sid=%s AND authenticated=%s', |
| 127 | 129 | (self.last_visit, self.sid, authenticated)) |