summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-06-16 14:18:57 +0200
committerAleksander Machniak <alec@alec.pl>2013-06-16 14:18:57 +0200
commit3dbe4f79e42dc655444187e22356994a0d5c76ce (patch)
treeb5d17825136b10b6224edbca1753d1fee1e0645d /program/lib/Roundcube/rcube.php
parentac1a962b51531ccbbaa6c41c329aa5f80859a39d (diff)
Fix session issues when local and database time differs (#1486132)
Improve performance by executing session gc on script shutdown, also call session_write_close() ASAP
Diffstat (limited to 'program/lib/Roundcube/rcube.php')
-rw-r--r--program/lib/Roundcube/rcube.php27
1 files changed, 9 insertions, 18 deletions
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 8d17827be..21b49f49b 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -99,7 +99,6 @@ class rcube
protected $texts;
protected $caches = array();
protected $shutdown_functions = array();
- protected $expunge_cache = false;
/**
@@ -462,7 +461,7 @@ class rcube
// use database for storing session data
$this->session = new rcube_session($this->get_dbh(), $this->config);
- $this->session->register_gc_handler(array($this, 'gc_handler'));
+ $this->session->register_gc_handler(array($this, 'gc'));
$this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME']));
$this->session->set_ip_check($this->config->get('ip_check'));
@@ -512,18 +511,6 @@ class rcube
/**
- * Garbage collector for cache entries.
- * Set flag to expunge caches on shutdown
- */
- public function gc_handler()
- {
- // because this gc function is called before storage is initialized,
- // we just set a flag to expunge storage cache on shutdown.
- $this->expunge_cache = true;
- }
-
-
- /**
* Runs garbage collector with probability based on
* session settings. This is intended for environments
* without a session.
@@ -922,12 +909,16 @@ class rcube
call_user_func($function);
}
- if (is_object($this->smtp)) {
- $this->smtp->disconnect();
+ // write session data as soon as possible and before
+ // closing database connection, don't do this before
+ // registered shutdown functions, they may need the session
+ // Note: this will run registered gc handlers (ie. cache gc)
+ if ($_SERVER['REMOTE_ADDR'] && is_object($this->session)) {
+ $this->session->write_close();
}
- if ($this->expunge_cache) {
- $this->gc();
+ if (is_object($this->smtp)) {
+ $this->smtp->disconnect();
}
foreach ($this->caches as $cache) {