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:
commit
1fbe6157ba
|
@ -159,6 +159,8 @@ trait PdoTrait
|
||||||
$delete = $this->getConnection()->prepare($deleteSql);
|
$delete = $this->getConnection()->prepare($deleteSql);
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
return true;
|
return true;
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
$delete->bindValue(':time', time(), \PDO::PARAM_INT);
|
$delete->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||||
|
|
||||||
|
@ -169,6 +171,8 @@ trait PdoTrait
|
||||||
return $delete->execute();
|
return $delete->execute();
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
return true;
|
return true;
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,6 +248,7 @@ trait PdoTrait
|
||||||
try {
|
try {
|
||||||
$conn->exec($sql);
|
$conn->exec($sql);
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
|
} catch (\PDOException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -260,6 +265,7 @@ trait PdoTrait
|
||||||
$stmt = $this->getConnection()->prepare($sql);
|
$stmt = $this->getConnection()->prepare($sql);
|
||||||
$stmt->execute(array_values($ids));
|
$stmt->execute(array_values($ids));
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
|
} catch (\PDOException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -316,6 +322,11 @@ trait PdoTrait
|
||||||
$this->createTable();
|
$this->createTable();
|
||||||
}
|
}
|
||||||
$stmt = $conn->prepare($sql);
|
$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) {
|
if ('sqlsrv' === $driver || 'oci' === $driver) {
|
||||||
|
@ -350,6 +361,11 @@ trait PdoTrait
|
||||||
$this->createTable();
|
$this->createTable();
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$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()) {
|
if (null === $driver && !$stmt->rowCount()) {
|
||||||
try {
|
try {
|
||||||
|
|
Reference in New Issue