diff --git a/CHANGELOG b/CHANGELOG index 25174cbb0..1f2e11665 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Skip redundant INSERT query on successful logon when using PHP7 - Replace display_version with display_product_version (#5904) - Extend disabled_actions config so it accepts also button names (#5903) - Handle remote stylesheets the same as remote images, ask the user to allow them (#5994) diff --git a/program/lib/Roundcube/rcube_session.php b/program/lib/Roundcube/rcube_session.php index 9fc564fac..33bcaddc3 100644 --- a/program/lib/Roundcube/rcube_session.php +++ b/program/lib/Roundcube/rcube_session.php @@ -45,6 +45,7 @@ abstract class rcube_session protected $cookiename = 'roundcube_sessauth'; protected $ip_check = false; protected $logging = false; + protected $ignore_write = false; /** @@ -274,11 +275,16 @@ abstract class rcube_session * Generate and set new session id * * @param boolean $destroy If enabled the current session will be destroyed + * * @return bool */ - public function regenerate_id($destroy=true) + public function regenerate_id($destroy = true) { + // Since PHP 7.0 session_regenerate_id() will cause the old + // session data update, we don't need this + $this->ignore_write = true; session_regenerate_id($destroy); + $this->ignore_write = false; $this->vars = null; $this->key = session_id(); diff --git a/program/lib/Roundcube/rcube_session_db.php b/program/lib/Roundcube/rcube_session_db.php index 892fc7fe8..269a80c12 100644 --- a/program/lib/Roundcube/rcube_session_db.php +++ b/program/lib/Roundcube/rcube_session_db.php @@ -123,6 +123,10 @@ class rcube_session_db extends rcube_session */ public function write($key, $vars) { + if ($this->ignore_write) { + return true; + } + $now = $this->db->now(); $this->db->query("INSERT INTO {$this->table_name}" diff --git a/program/lib/Roundcube/rcube_session_memcache.php b/program/lib/Roundcube/rcube_session_memcache.php index 7d153f537..8210bd6d2 100644 --- a/program/lib/Roundcube/rcube_session_memcache.php +++ b/program/lib/Roundcube/rcube_session_memcache.php @@ -126,6 +126,10 @@ class rcube_session_memcache extends rcube_session */ public function write($key, $vars) { + if ($this->ignore_write) { + return true; + } + $data = serialize(array('changed' => time(), 'ip' => $this->ip, 'vars' => $vars)); $result = $this->memcache->set($key, $data, MEMCACHE_COMPRESSED, $this->lifetime + 60); diff --git a/program/lib/Roundcube/rcube_session_redis.php b/program/lib/Roundcube/rcube_session_redis.php index 7a72b1fc1..4a7a8650e 100644 --- a/program/lib/Roundcube/rcube_session_redis.php +++ b/program/lib/Roundcube/rcube_session_redis.php @@ -202,6 +202,10 @@ class rcube_session_redis extends rcube_session { */ public function write($key, $vars) { + if ($this->ignore_write) { + return true; + } + $data = serialize(array('changed' => time(), 'ip' => $this->ip, 'vars' => $vars)); return $this->redis->setex($key, $this->lifetime + 60, $data);