8000 [Cache] fix create table at prepare time · symfony/symfony@f419851 · GitHub
[go: up one dir, main page]

Skip to content

Commit f419851

Browse files
[Cache] fix create table at prepare time
1 parent 82617b9 commit f419851

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Component/Cache/Traits/PdoTrait.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,14 @@ protected function doSave(array $values, $lifetime)
306306

307307
$now = time();
308308
$lifetime = $lifetime ?: null;
309-
$stmt = $conn->prepare($sql);
309+
try {
310+
$stmt = $conn->prepare($sql);
311+
} catch (TableNotFoundException $e) {
312+
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
313+
$this->createTable();
314+
}
315+
$stmt = $conn->prepare($sql);
316+
}
310317

311318
if ('sqlsrv' === $driver || 'oci' === $driver) {
312319
$stmt->bindParam(1, $id);

0 commit comments

Comments
 (0)
0