Compare commits
No commits in common. "fd286c9cffadc4a26609bfa00944f8014a2f3f59" and "0da1d00c3d67754b15b1984fb23ccc9febd03d32" have entirely different histories.
fd286c9cff
...
0da1d00c3d
@ -13,17 +13,14 @@ class DatabaseSessionHandler implements ISessionHandler
|
|||||||
|
|
||||||
private string $table;
|
private string $table;
|
||||||
|
|
||||||
private DateTime $shouldBeNewerThan;
|
|
||||||
|
|
||||||
private bool $exists = false;
|
private bool $exists = false;
|
||||||
|
|
||||||
private bool $written = false;
|
private bool $written = false;
|
||||||
|
|
||||||
public function __construct(IConnection $dbConnection, string $table, DateTime $shouldBeNewerThan)
|
public function __construct(IConnection $dbConnection, string $table)
|
||||||
{
|
{
|
||||||
$this->dbConnection = $dbConnection;
|
$this->dbConnection = $dbConnection;
|
||||||
$this->table = $table;
|
$this->table = $table;
|
||||||
$this->shouldBeNewerThan = $shouldBeNewerThan;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function open($savePath, $sessionName): bool
|
public function open($savePath, $sessionName): bool
|
||||||
@ -39,20 +36,17 @@ class DatabaseSessionHandler implements ISessionHandler
|
|||||||
public function read($id): string
|
public function read($id): string
|
||||||
{
|
{
|
||||||
$select = new Select($this->dbConnection, $this->table);
|
$select = new Select($this->dbConnection, $this->table);
|
||||||
$select->columns(['data', 'updated']);
|
$select->columns(['data']);
|
||||||
$select->whereId(substr($id, 0, 32));
|
$select->whereId(substr($id, 0, 32));
|
||||||
|
|
||||||
$result = $select->execute()->fetch(IResultSet::FETCH_ASSOC);
|
$result = $select->execute()->fetch(IResultSet::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($result === null) {
|
if ($result === null) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->exists = true;
|
$this->exists = true;
|
||||||
|
|
||||||
if (new DateTime($result['updated']) < $this->shouldBeNewerThan) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result['data'];
|
return $result['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user