Skip to content

Commit 3ae61ec

Browse files
bug #37563 Fix DBAL deprecation (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- Fix DBAL deprecation | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Follows doctrine/dbal#4163 Commits ------- 4273aed Fix DBAL deprecation
2 parents a56f648 + 4273aed commit 3ae61ec

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ public function deleteTokenBySeries($series)
8181
$sql = 'DELETE FROM rememberme_token WHERE series=:series';
8282
$paramValues = ['series' => $series];
8383
$paramTypes = ['series' => \PDO::PARAM_STR];
84-
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
84+
if (method_exists($this->conn, 'executeStatement')) {
85+
$this->conn->executeStatement($sql, $paramValues, $paramTypes);
86+
} else {
87+
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
88+
}
8589
}
8690

8791
/**
@@ -101,7 +105,11 @@ public function updateToken($series, $tokenValue, \DateTime $lastUsed)
101105
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
102106
'series' => \PDO::PARAM_STR,
103107
];
104-
$updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes);
108+
if (method_exists($this->conn, 'executeStatement')) {
109+
$updated = $this->conn->executeStatement($sql, $paramValues, $paramTypes);
110+
} else {
111+
$updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes);
112+
}
105113
if ($updated < 1) {
106114
throw new TokenNotFoundException('No token found.');
107115
}
@@ -129,6 +137,10 @@ public function createNewToken(PersistentTokenInterface $token)
129137
'value' => \PDO::PARAM_STR,
130138
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
131139
];
132-
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
140+
if (method_exists($this->conn, 'executeStatement')) {
141+
$this->conn->executeStatement($sql, $paramValues, $paramTypes);
142+
} else {
143+
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
144+
}
133145
}
134146
}

src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private function bootstrapProvider()
7272
'driver' => 'pdo_sqlite',
7373
'url' => 'sqlite:///:memory:',
7474
]);
75-
$connection->executeUpdate(<<< 'SQL'
75+
$connection->{method_exists($this->conn, 'executeStatement') ? 'executeStatement' : 'executeUpdate'}(<<< 'SQL'
7676
CREATE TABLE rememberme_token (
7777
series char(88) UNIQUE PRIMARY KEY NOT NULL,
7878
value char(88) NOT NULL,

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ public function createTable()
107107
$table->setPrimaryKey([$this->idCol]);
108108

109109
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
110-
$conn->exec($sql);
110+
if (method_exists($conn, 'executeStatement')) {
111+
$conn->executeStatement($sql);
112+
} else {
113+
$conn->exec($sql);
114+
}
111115
}
112116

113117
return;
@@ -138,7 +142,11 @@ public function createTable()
138142
throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver));
139143
}
140144

141-
$conn->exec($sql);
145+
if (method_exists($conn, 'executeStatement')) {
146+
$conn->executeStatement($sql);
147+
} else {
148+
$conn->exec($sql);
149+
}
142150
}
143151

144152
/**
@@ -238,7 +246,11 @@ protected function doClear($namespace)
238246
$sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'";
239247
}
240248

241-
$conn->exec($sql);
249+
if (method_exists($conn, 'executeStatement')) {
250+
$conn->executeStatement($sql);
251+
} else {
252+
$conn->exec($sql);
253+
}
242254

243255
return true;
244256
}

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