Skip to content

Commit f94d67b

Browse files
committed
catch exceptions when using PDO directly
1 parent 83dca34 commit f94d67b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Traits/PdoTrait.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public function prune()
159159
$delete = $this->getConnection()->prepare($deleteSql);
160160
} catch (TableNotFoundException $e) {
161161
return true;
162+
} catch (\PDOException $e) {
163+
return true;
162164
}
163165
$delete->bindValue(':time', time(), \PDO::PARAM_INT);
164166

@@ -169,6 +171,8 @@ public function prune()
169171
return $delete->execute();
170172
} catch (TableNotFoundException $e) {
171173
return true;
174+
} catch (\PDOException $e) {
175+
return true;
172176
}
173177
}
174178

@@ -244,6 +248,7 @@ protected function doClear($namespace)
244248
try {
245249
$conn->exec($sql);
246250
} catch (TableNotFoundException $e) {
251+
} catch (\PDOException $e) {
247252
}
248253

249254
return true;
@@ -260,6 +265,7 @@ protected function doDelete(array $ids)
260265
$stmt = $this->getConnection()->prepare($sql);
261266
$stmt->execute(array_values($ids));
262267
} catch (TableNotFoundException $e) {
268+
} catch (\PDOException $e) {
263269
}
264270

265271
return true;
@@ -316,6 +322,11 @@ protected function doSave(array $values, $lifetime)
316322
$this->createTable();
317323
}
318324
$stmt = $conn->prepare($sql);
325+
} catch (\PDOException $e) {
326+
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
327+
$this->createTable();
328+
}
329+
$stmt = $conn->prepare($sql);
319330
}
320331

321332
if ('sqlsrv' === $driver || 'oci' === $driver) {
@@ -350,6 +361,11 @@ protected function doSave(array $values, $lifetime)
350361
$this->createTable();
351362
}
352363
$stmt->execute();
364+
} catch (\PDOException $e) {
365+
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
366+
$this->createTable();
367+
}
368+
$stmt->execute();
353369
}
354370
if (null === $driver && !$stmt->rowCount()) {
355371
try {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy