Skip redundant INSERT query on successful logon when using PHP7

Since PHP 7.0 session_regenerate_id() will cause the old session data update.
This is redundant INSERT query and also produces a record for the session
we don't need anymore.
pull/6011/head
Aleksander Machniak 7 years ago
parent c4aadca1c0
commit 0f4f85e097

@ -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)

@ -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();

@ -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}"

@ -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);

@ -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);

Loading…
Cancel
Save