Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Fix 'cache' table cleanup on session destroy (#1485516)

  • Loading branch information...
commit be7d3b6918ff90757d10804ac914edb5a65f4828 1 parent bd0c2b0
Aleksander Machniak alecpl authored
4 CHANGELOG
View
@@ -1,6 +1,10 @@
CHANGELOG RoundCube Webmail
---------------------------
+2008/11/21 (alec)
+----------
+- Fix 'cache' table cleanup on session destroy (#1485516)
+
2008/11/19 (alec)
----------
- Fix handling of some malformed messages (#1484438)
8 SQL/mysql.update.sql
View
@@ -30,3 +30,11 @@ ALTER TABLE `identities`
ALTER TABLE `messages`
ADD INDEX `created_index` (`created`);
+
+-- Updates from version 0.2-beta (InnoDB only)
+
+ALTER TABLE `cache`
+ ADD CONSTRAINT `session_id_fk_cache` FOREIGN KEY (`session_id`)
+ REFERENCES `session`(`sess_id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE;
4 SQL/mysql5.initial.sql
View
@@ -77,6 +77,10 @@ CREATE TABLE `cache` (
CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`)
ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `session_id_fk_cache` FOREIGN KEY (`session_id`)
+ REFERENCES `session`(`sess_id`)
+ ON DELETE CASCADE
ON UPDATE CASCADE
) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci;
3  SQL/postgres.initial.sql
View
@@ -128,13 +128,14 @@ CREATE SEQUENCE cache_ids
CREATE TABLE "cache" (
cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY,
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
- session_id character varying(40) REFERENCES "session" (sess_id),
+ session_id character varying(40) REFERENCES "session" (sess_id) ON DELETE CASCADE ON UPDATE CASCADE,
cache_key character varying(128) DEFAULT ''::character varying NOT NULL,
created timestamp with time zone DEFAULT now() NOT NULL,
data text NOT NULL
);
CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key);
+CREATE INDEX cache_session_id_idx ON "cache" (session_id);
--
-- Sequence "message_ids"
6 SQL/postgres.update.sql
View
@@ -21,3 +21,9 @@ ALTER TABLE cache ADD FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE
-- Updates from version 0.2-alpha
CREATE INDEX messages_created_idx ON messages (created);
+
+-- Updates from version 0.2-beta
+
+ALTER TABLE cache DROP CONSTRAINT cache_session_id_fkey;
+ALTER TABLE cache ADD FOREIGN KEY (session_id) REFERENCES session(sess_id) ON DELETE CASCADE ON UPDATE CASCADE;
+CREATE INDEX cache_session_id_idx ON "cache" (session_id);
11 program/include/rcube_imap.php
View
@@ -2146,11 +2146,11 @@ function _write_cache_record($key, $data)
{
$this->db->query(
"UPDATE ".get_table_name('cache')."
- SET created=".$this->db->now().",
- data=?
+ SET created=".$this->db->now().", data=?, session_id=?
WHERE user_id=?
AND cache_key=?",
$data,
+ session_id(),
$_SESSION['user_id'],
$key);
}
@@ -2159,11 +2159,12 @@ function _write_cache_record($key, $data)
{
$this->db->query(
"INSERT INTO ".get_table_name('cache')."
- (created, user_id, cache_key, data)
- VALUES (".$this->db->now().", ?, ?, ?)",
+ (created, user_id, cache_key, data, session_id)
+ VALUES (".$this->db->now().", ?, ?, ?, ?)",
$_SESSION['user_id'],
$key,
- $data);
+ $data,
+ session_id());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.