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

Skip to content

Commit 41b835a

Browse files
committed
[Lock] MysqlStore::putOffExpiration ping the connection to ensure it is alive
1 parent c0f10a4 commit 41b835a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Symfony/Component/Lock/Store/MysqlStore.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function waitAndSave(Key $key)
7171

7272
private function lock(Key $key, bool $blocking)
7373
{
74-
// The lock is maybe already acquired.
74+
// the lock is maybe already acquired.
7575
if ($key->hasState(__CLASS__)) {
7676
return;
7777
}
@@ -102,7 +102,7 @@ private function lock(Key $key, bool $blocking)
102102
}
103103

104104
// store the release statement in the state
105-
$releaseStmt = $this->connection->prepare('SELECT RELEASE_LOCK(:key)');
105+
$releaseStmt = $this->connection->prepare('DO RELEASE_LOCK(:key)');
106106
$releaseStmt->bindValue(':key', $storedKey, \PDO::PARAM_STR);
107107

108108
$key->setState(__CLASS__, $releaseStmt);
@@ -113,7 +113,9 @@ private function lock(Key $key, bool $blocking)
113113
*/
114114
public function putOffExpiration(Key $key, $ttl)
115115
{
116-
// do nothing, the GET_LOCK locks forever, until the session terminates.
116+
// the GET_LOCK locks forever, until the session terminates.
117+
// keep the session open
118+
$this->connection->exec('DO 1');
117119
}
118120

119121
/**

0 commit comments

Comments
 (0)