From d65f9eeb5c0045b545ee8027fe9ed9348a61c059 Mon Sep 17 00:00:00 2001 From: "G.R.Dalenoort" Date: Tue, 5 Oct 2021 22:25:29 +0200 Subject: [PATCH] fix SQLSRV throws for method_exists() pdo_sqlsrv driver 5.9.0 throws an exception for any call on method_exists(). (see microsoft/msphpsql/issues/1306) executeStatement() is a DBAL-method, exec() is PDO. fix by excluding method_exists() check on PDO type of connections --- src/Symfony/Component/Cache/Traits/PdoTrait.php | 4 ++-- src/Symfony/Component/Lock/Store/PdoStore.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index 2f733a78e1307..5b0461409cfb5 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -150,7 +150,7 @@ public function createTable() throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); } - if (method_exists($conn, 'executeStatement')) { + if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) { $conn->executeStatement($sql); } else { $conn->exec($sql); @@ -282,7 +282,7 @@ protected function doClear($namespace) } try { - if (method_exists($conn, 'executeStatement')) { + if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) { $conn->executeStatement($sql); } else { $conn->exec($sql); diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index 98c6454e3669d..cd24c4def6602 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -268,7 +268,7 @@ public function createTable(): void $table->setPrimaryKey([$this->idCol]); foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) { - if (method_exists($conn, 'executeStatement')) { + if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) { $conn->executeStatement($sql); } else { $conn->exec($sql); @@ -298,7 +298,7 @@ public function createTable(): void throw new \DomainException(sprintf('Creating the lock table is currently not implemented for PDO driver "%s".', $driver)); } - if (method_exists($conn, 'executeStatement')) { + if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) { $conn->executeStatement($sql); } else { $conn->exec($sql); @@ -313,7 +313,7 @@ private function prune(): void $sql = "DELETE FROM $this->table WHERE $this->expirationCol <= {$this->getCurrentTimestampStatement()}"; $conn = $this->getConnection(); - if (method_exists($conn, 'executeStatement')) { + if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) { $conn->executeStatement($sql); } else { $conn->exec($sql);