10000 bug #25922 [HttpFoundation] Use the correct syntax for session gc bas… · symfony/symfony@5e3aa67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e3aa67

Browse files
committed
bug #25922 [HttpFoundation] Use the correct syntax for session gc based on Pdo driver (tanasecosminromeo)
This PR was submitted for the master branch but it was squashed and merged into the 2.7 branch instead (closes #25922). Discussion ---------- [HttpFoundation] Use the correct syntax for session gc based on Pdo driver | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25665 #24456 | License | MIT | Doc PR | The initial fix for #24456 was wrong, since it only accounted for Postgres. @WhiteEagle88 correctly identified #25665 - but having time as SIGNED is ... off, since time shouldn't be negative. Using CAST to solve this issue surely has a performance penalty, so I believe the best approach is to have a switch based on the driver. Commits ------- 826dfbd [HttpFoundation] Use the correct syntax for session gc based on Pdo driver
2 parents 4f47bb7 + 826dfbd commit 5e3aa67

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,11 @@ public function close()
375375
$this->gcCalled = false;
376376

377377
// delete the session records that have expired
378-
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol < :time - $this->timeCol";
378+
if ('mysql' === $this->driver) {
379+
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol < :time";
380+
} else {
381+
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol < :time - $this->timeCol";
382+
}
379383

380384
$stmt = $this->pdo->prepare($sql);
381385
$stmt->bindValue(':time', time(), \PDO::PARAM_INT) 39CE ;

0 commit comments

Comments
 (0)
0