8000 bug #43330 [Cache][Lock] fix SQLSRV throws for method_exists() (GDmac) · symfony/symfony@37d26fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 37d26fb

Browse files
committed
bug #43330 [Cache][Lock] fix SQLSRV throws for method_exists() (GDmac)
This PR was merged into the 4.4 branch. Discussion ---------- [Cache][Lock] fix SQLSRV throws for method_exists() pdo_sqlsrv driver 5.9.0 always throws an exception for any call on method_exists(). (see microsoft/msphpsql/issues/1306) ```executeStatement()``` is a DBAL-method, and ```exec()``` is PDO. fix by excluding method_exists() on PDO type of connections | Q | A | ------------- | --- | Branch? | 4.4 (and later) | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT Commits ------- d65f9ee fix SQLSRV throws for method_exists()
2 parents 57f5df5 + d65f9ee commit 37d26fb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Symfony/Component/Cache/Traits/PdoTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function createTable()
150150
throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver));
151151
}
152152

153-
if (method_exists($conn, 'executeStatement')) {
153+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
154154
$conn->executeStatement($sql);
155155
} else {
156156
$conn->exec($sql);
@@ -282,7 +282,7 @@ protected function doClear($namespace)
282282
}
283283

284284
try {
285-
if (method_exists($conn, 'executeStatement')) {
285+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
286286
$conn->executeStatement($sql);
287287
} else {
288288
$conn->exec($sql);

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function createTable(): void
268268
$table->setPrimaryKey([$this->idCol]);
269269

270270
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
271-
if (method_exists($conn, 'executeStatement')) {
271+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
272272
$conn->executeStatement($sql);
273273
} else {
274274
$conn->exec($sql);
@@ -298,7 +298,7 @@ public function createTable(): void
298298
throw new \DomainException(sprintf('Creating the lock table is currently not implemented for PDO driver "%s".', $driver));
299299
}
300300

301-
if (method_exists($conn, 'executeStatement')) {
301+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
302302
$conn->executeStatement($sql);
303303
} else {
304304
$conn->exec($sql);
@@ -313,7 +313,7 @@ private function prune(): void
313313
$sql = "DELETE FROM $this->table WHERE $this->expirationCol <= {$this->getCurrentTimestampStatement()}";
314314

315315
$conn = $this->getConnection();
316-
if (method_exists($conn, 'executeStatement')) {
316+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
317317
$conn->executeStatement($sql);
318318
} else {
319319
$conn->exec($sql);

0 commit comments

Comments
 (0)
0