From 81d3716b0d8e29f4268208383d8321f19f0d13e5 Mon Sep 17 00:00:00 2001 From: Alex Teterin <7018407@gmail.com> Date: Wed, 16 Jan 2019 10:26:23 +0300 Subject: [PATCH] [Cache] PDO-based cache pool table autocreation does not work --- .../Component/Cache/Traits/PdoTrait.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index 9917bd91f545a..6d896fd55514e 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -306,14 +306,7 @@ protected function doSave(array $values, $lifetime) $now = time(); $lifetime = $lifetime ?: null; - try { - $stmt = $conn->prepare($sql); - } catch (TableNotFoundException $e) { - if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { - $this->createTable(); - } - $stmt = $conn->prepare($sql); - } + $stmt = $conn->prepare($sql); if ('sqlsrv' === $driver || 'oci' === $driver) { $stmt->bindParam(1, $id); @@ -340,8 +333,14 @@ protected function doSave(array $values, $lifetime) } foreach ($values as $id => $data) { - $stmt->execute(); - + try { + $stmt->execute(); + } catch (TableNotFoundException $e) { + if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { + $this->createTable(); + } + $stmt->execute(); + } if (null === $driver && !$stmt->rowCount()) { try { $insertStmt->execute();