bug #34408 [Cache] catch exceptions when using PDO directly (xabbuh)

This PR was merged into the 4.3 branch.

Discussion
----------

[Cache] catch exceptions when using PDO directly

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix symfony/symfony-docs#12632
| License       | MIT
| Doc PR        |

Commits
-------

5c1f5594f5 catch exceptions when using PDO directly
This commit is contained in:
Nicolas Grekas 2019-11-16 18:08:55 +01:00
commit 1fbe6157ba
1 changed files with 16 additions and 0 deletions

View File

@ -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 {