From 5c1f5594f5104a97eba28cc9c49e00e78ccdc401 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 16 Nov 2019 10:57:45 +0100 Subject: [PATCH] catch exceptions when using PDO directly --- src/Symfony/Component/Cache/Traits/PdoTrait.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index ec34e72fb5..b636e7565b 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -159,6 +159,8 @@ trait PdoTrait $delete = $this->getConnection()->prepare($deleteSql); } catch (TableNotFoundException $e) { return true; + } catch (\PDOException $e) { + return true; } $delete->bindValue(':time', time(), \PDO::PARAM_INT); @@ -169,6 +171,8 @@ trait PdoTrait return $delete->execute(); } catch (TableNotFoundException $e) { return true; + } catch (\PDOException $e) { + return true; } } @@ -244,6 +248,7 @@ trait PdoTrait try { $conn->exec($sql); } catch (TableNotFoundException $e) { + } catch (\PDOException $e) { } return true; @@ -260,6 +265,7 @@ trait PdoTrait $stmt = $this->getConnection()->prepare($sql); $stmt->execute(array_values($ids)); } catch (TableNotFoundException $e) { + } catch (\PDOException $e) { } return true; @@ -316,6 +322,11 @@ trait PdoTrait $this->createTable(); } $stmt = $conn->prepare($sql); + } catch (\PDOException $e) { + if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { + $this->createTable(); + } + $stmt = $conn->prepare($sql); } if ('sqlsrv' === $driver || 'oci' === $driver) { @@ -350,6 +361,11 @@ trait PdoTrait $this->createTable(); } $stmt->execute(); + } catch (\PDOException $e) { + if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { + $this->createTable(); + } + $stmt->execute(); } if (null === $driver && !$stmt->rowCount()) { try {