bug #27250 [Session] limiting :key for GET_LOCK to 64 chars (oleg-andreyev)
This PR was merged into the 2.7 branch.
Discussion
----------
[Session] limiting :key for GET_LOCK to 64 chars
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
> MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced.
Cases:
- `session_id` is set by developers manually
- `session.sid_length` is configured
Ref.:
- https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock
- http://php.net/manual/en/session.configuration.php#ini.session.sid-length
Other issues:
- https://github.com/go-sql-driver/mysql/issues/385
- https://github.com/stefangabos/Zebra_Session/issues/16
Commits
-------
9cda96b8b5
#27250 limiting GET_LOCK key up to 64 char due to changes in MySQL 5.7.5 and later
This commit is contained in:
commit
974050feb8
@ -552,14 +552,16 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
||||
{
|
||||
switch ($this->driver) {
|
||||
case 'mysql':
|
||||
// MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced.
|
||||
$lockId = \substr($sessionId, 0, 64);
|
||||
// should we handle the return value? 0 on timeout, null on error
|
||||
// we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout
|
||||
$stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)');
|
||||
$stmt->bindValue(':key', $sessionId, \PDO::PARAM_STR);
|
||||
$stmt->bindValue(':key', $lockId, \PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
|
||||
$releaseStmt = $this->pdo->prepare('DO RELEASE_LOCK(:key)');
|
||||
$releaseStmt->bindValue(':key', $sessionId, \PDO::PARAM_STR);
|
||||
$releaseStmt->bindValue(':key', $lockId, \PDO::PARAM_STR);
|
||||
|
||||
return $releaseStmt;
|
||||
case 'pgsql':
|
||||
|
Reference in New Issue
Block a user