Skip to content

Commit b36d4be

Browse files
authored
Use CURRENT_TIMESTAMP
1 parent 5d5d946 commit b36d4be

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

system/Session/Handlers/DatabaseHandler.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function write($id, $data): bool
196196
'data' => $this->prepareData($data),
197197
];
198198

199-
if (! $this->db->table($this->table)->set('timestamp', $this->now(), false)->insert($insertData)) {
199+
if (! $this->db->table($this->table)->set('timestamp', 'CURRENT_TIMESTAMP', false)->insert($insertData)) {
200200
return $this->fail();
201201
}
202202

@@ -218,7 +218,7 @@ public function write($id, $data): bool
218218
$updateData['data'] = $this->prepareData($data);
219219
}
220220

221-
if (! $builder->set('timestamp', $this->now(), false)->update($updateData)) {
221+
if (! $builder->set('timestamp', 'CURRENT_TIMESTAMP', false)->update($updateData)) {
222222
return $this->fail();
223223
}
224224

@@ -307,20 +307,13 @@ protected function releaseLock(): bool
307307

308308
/**
309309
* Determines which NOW function to use based on DBDriver
310-
*
310+
*
311311
* @param string $interval Amount of time to subtract from NOW
312312
*/
313-
private function now($interval = null): string
313+
private function now($interval): string
314314
{
315315
$DBDriver = config(Database::class)->{$this->DBGroup}['DBDriver'];
316-
return null === $interval
317-
? match($DBDriver)
318-
{
319-
'SQLite3' => "datetime('now')",
320-
default => "now()",
321-
}
322-
: match($DBDriver)
323-
{
316+
return match($DBDriver) {
324317
'SQLite3' => "datetime('now', '-{$interval}')",
325318
default => "now() - INTERVAL {$interval}",
326319
};

0 commit comments

Comments
 (0)