Closed
Description
Symfony version(s) affected: 4.2.2
Description
\Symfony\Component\Cache\Traits\PdoTrait has bug, auto creation of cache table is not working.
How to reproduce
Just use "symfony/cache": "^4.2" and default_pdo_provider: database_connection, try to call ->save() method and no cache table will be created, i am using pgsql
This is the place where table must be auto-created but not:
try {
$stmt = $conn->prepare($sql);
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, array('pgsql', 'sqlite', 'sqlsrv'), true)) {
$this->createTable();
}
$stmt = $conn->prepare($sql);
}
Possible Solution
Wrap with catch not prepare but execute method, when $stmt->execute(); called and no cache table exists TableNotFoundException will be throwed
Additional context
I have insered some code here to try the fix:
related: #27694 (comment)