From 7bbbd3dd0d74a8eb68d06df0542d893b46ff66c3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 9 Jun 2020 13:46:03 +0200 Subject: [PATCH 1/3] [Lock] fix compat with doctrine/dbal v3 --- src/Symfony/Component/Lock/Store/PdoStore.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index 7af7f3870f..284c0ac262 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -14,6 +14,7 @@ namespace Symfony\Component\Lock\Store; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Result; use Doctrine\DBAL\Schema\Schema; use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\InvalidTtlException; @@ -168,10 +169,10 @@ class PdoStore implements StoreInterface $stmt->bindValue(':id', $this->getHashedKey($key)); $stmt->bindValue(':token1', $uniqueToken); $stmt->bindValue(':token2', $uniqueToken); - $stmt->execute(); + $result = $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 - if (!$stmt->rowCount() && !$this->exists($key)) { + if (!($result instanceof Result ? $result : $stmt)->rowCount() && !$this->exists($key)) { throw new LockConflictedException(); } @@ -201,9 +202,9 @@ class PdoStore implements StoreInterface $stmt->bindValue(':id', $this->getHashedKey($key)); $stmt->bindValue(':token', $this->getUniqueToken($key)); - $stmt->execute(); + $result = $stmt->execute(); - return (bool) (method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn()); + return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn()); } /** From 0f7630892923c9a532177608ca835af89d6ce7ab Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 9 Jun 2020 13:48:38 +0200 Subject: [PATCH 2/3] [Cache] fix compat with doctrine/dbal v3 --- src/Symfony/Component/Cache/Traits/PdoTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index b00cd930aa..b8bd2255ac 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -337,9 +337,9 @@ trait PdoTrait } foreach ($serialized as $id => $data) { - $stmt->execute(); + $result = $stmt->execute(); - if (null === $driver && !$stmt->rowCount()) { + if (null === $driver && !($result instanceof Result ? $result : $stmt)->rowCount()) { try { $insertStmt->execute(); } catch (DBALException $e) { From ef6fc092605770ad81fa60c7cff5cf1d62a17257 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 9 Jun 2020 14:06:18 +0200 Subject: [PATCH 3/3] [Cache] fix parse error on PHP 5.5 --- src/Symfony/Component/Cache/Traits/PdoTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index b8bd2255ac..fd6101d351 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -339,7 +339,7 @@ trait PdoTrait foreach ($serialized as $id => $data) { $result = $stmt->execute(); - if (null === $driver && !($result instanceof Result ? $result : $stmt)->rowCount()) { + if (null === $driver && !($result instanceof Result ? $result->rowCount() : $stmt->rowCount())) { try { $insertStmt->execute(); } catch (DBALException $e) {