Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c52bc6

Browse files
committed
#27250 limiting GET_LOCK key up to 64 char due to changes in MySQL 5.7.5 and later
1 parent d7d4e41 commit 4c52bc6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,17 @@ private function doAdvisoryLock($sessionId)
552552
{
553553
switch ($this->driver) {
554554
case 'mysql':
555+
// MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced.
556+
$lockId = \substr($sessionId, 0, 64);
557+
555558
// should we handle the return value? 0 on timeout, null on error
556559
// we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout
557560
$stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)');
558-
$stmt->bindValue(':key', $sessionId, \PDO::PARAM_STR);
561+
$stmt->bindValue(':key', $lockId, \PDO::PARAM_STR);
559562
$stmt->execute();
560563

561564
$releaseStmt = $this->pdo->prepare('DO RELEASE_LOCK(:key)');
562-
$releaseStmt->bindValue(':key', $sessionId, \PDO::PARAM_STR);
565+
$releaseStmt->bindValue(':key', $lockId, \PDO::PARAM_STR);
563566

564567
return $releaseStmt;
565568
case 'pgsql':

0 commit comments

Comments
 (0)