Skip to content

Commit

Permalink
bug #29900 [Cache] PDO-based cache pool table autocreation does not w…
Browse files Browse the repository at this point in the history
…ork (errogaht)

This PR was merged into the 4.2 branch.

Discussion
----------

[Cache] PDO-based cache pool table autocreation does not work

look at #29898
I believe that it is not good fix... But pgsq table not foutd throwed right there, in execute(). Dont know about another DB drivers, and i dont know will execute() again work or not, please if some one know more about PDO than me, check it!

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29898
| License       | MIT

Commits
-------

81d3716 [Cache] PDO-based cache pool table autocreation does not work
  • Loading branch information
nicolas-grekas committed Jan 25, 2019
2 parents a0ea84b + 81d3716 commit f7b9bb2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Symfony/Component/Cache/Traits/PdoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,7 @@ protected function doSave(array $values, $lifetime)

$now = time();
$lifetime = $lifetime ?: null;
try {
$stmt = $conn->prepare($sql);
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt = $conn->prepare($sql);
}
$stmt = $conn->prepare($sql);

if ('sqlsrv' === $driver || 'oci' === $driver) {
$stmt->bindParam(1, $id);
Expand All @@ -340,8 +333,14 @@ protected function doSave(array $values, $lifetime)
}

foreach ($values as $id => $data) {
$stmt->execute();

try {
$stmt->execute();
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt->execute();
}
if (null === $driver && !$stmt->rowCount()) {
try {
$insertStmt->execute();
Expand Down

0 comments on commit f7b9bb2

Please sign in to comment.