Skip to content

Commit

Permalink
Fix bug where session could time out if DB and PHP timezone were diff…
Browse files Browse the repository at this point in the history
…erent (#8303)
  • Loading branch information
alecpl committed Mar 13, 2022
1 parent 3516084 commit 96e9427
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## Unreleased

- Enigma: Fix initial synchronization of private keys
- Fix handling of message/rfc822 parts that are small and are multipart structures with a single part (#8458)
- Fix various PHP8 warnings (#8392)
- Fix mail headers injection via the subject field on mail compose (#8404)
- Fix bug where small message/rfc822 parts could not be decoded (#8408)
Expand All @@ -12,6 +11,7 @@
- Fix bug where some mail parts (images) could have not be listed as attachments (#8425)
- Fix bug where attachment icons were stuck at the top of the messages list in Safari (#8433)
- Fix handling of message/rfc822 parts that are small and are multipart structures with a single part (#8458)
- Fix bug where session could time out if DB and PHP timezone were different (#8303)

## Release 1.5.2

Expand Down
1 change: 0 additions & 1 deletion program/lib/Roundcube/rcube_session.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ abstract class rcube_session
protected $vars;
protected $now;
protected $lifetime;
protected $time_diff = 0;
protected $reloaded = false;
protected $appends = [];
protected $unsets = [];
Expand Down
9 changes: 5 additions & 4 deletions program/lib/Roundcube/session/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public function read($key)
return '';
}

$this->time_diff = time() - strtotime($sql_arr['ts']);
$this->changed = strtotime($sql_arr['changed']);
$time_diff = time() - strtotime($sql_arr['ts']);

$this->changed = strtotime($sql_arr['changed']) + $time_diff; // local (PHP) time
$this->ip = $sql_arr['ip'];
$this->vars = base64_decode($sql_arr['vars']);
$this->key = $key;
Expand Down Expand Up @@ -183,7 +184,7 @@ public function update($key, $newvars, $oldvars)
. "SET `changed` = $now, `vars` = ? WHERE `sess_id` = ?",
base64_encode($newvars), $key);
}
else if ($ts - $this->changed + $this->time_diff > $this->lifetime / 2) {
else if ($ts - $this->changed > $this->lifetime / 2) {
$this->db->query("UPDATE {$this->table_name} SET `changed` = $now"
. " WHERE `sess_id` = ?", $key);
}
Expand All @@ -198,7 +199,7 @@ public function gc_db()
{
// just clean all old sessions when this GC is called
$this->db->query("DELETE FROM " . $this->db->table_name('session')
. " WHERE changed < " . $this->db->now(-$this->gc_enabled));
. " WHERE `changed` < " . $this->db->now(-$this->gc_enabled));

$this->log("Session GC (DB): remove records < "
. date('Y-m-d H:i:s', time() - $this->gc_enabled)
Expand Down

1 comment on commit 96e9427

@bombcheck
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed files in my installation as shown here, but the problem still exists...

Please sign in to comment.