From a639301cd6584bea7dcb58152d056235a7ead040 Mon Sep 17 00:00:00 2001 From: Pavel Prischepa Date: Mon, 19 Nov 2018 18:59:39 +0700 Subject: [PATCH] [Lock] Fixed PDOStatement exception "Invalid parameter number" in putOffExpiration() --- src/Symfony/Component/Lock/Store/PdoStore.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index da6a50df5d..710eca668f 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -164,11 +164,13 @@ class PdoStore implements StoreInterface $key->reduceLifetime($ttl); - $sql = "UPDATE $this->table SET $this->expirationCol = {$this->getCurrentTimestampStatement()} + $ttl, $this->tokenCol = :token WHERE $this->idCol = :id AND ($this->tokenCol = :token OR $this->expirationCol <= {$this->getCurrentTimestampStatement()})"; + $sql = "UPDATE $this->table SET $this->expirationCol = {$this->getCurrentTimestampStatement()} + $ttl, $this->tokenCol = :token1 WHERE $this->idCol = :id AND ($this->tokenCol = :token2 OR $this->expirationCol <= {$this->getCurrentTimestampStatement()})"; $stmt = $this->getConnection()->prepare($sql); + $uniqueToken = $this->getUniqueToken($key); $stmt->bindValue(':id', $this->getHashedKey($key)); - $stmt->bindValue(':token', $this->getUniqueToken($key)); + $stmt->bindValue(':token1', $uniqueToken); + $stmt->bindValue(':token2', $uniqueToken); $stmt->execute(); // If this method is called twice in the same second, the row wouldn't be updated. We have to call exists to know if we are the owner @@ -214,7 +216,7 @@ class PdoStore implements StoreInterface */ private function getHashedKey(Key $key): string { - return hash('sha256', $key); + return hash('sha256', (string) $key); } private function getUniqueToken(Key $key): string