Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite98c584

Browse files
committed
Fix the DBAL session handler version check for Postgresql
1 parentd303b9d commite98c584

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

‎src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
useDoctrine\DBAL\Connection;
1515
useDoctrine\DBAL\Driver\DriverException;
16+
useDoctrine\DBAL\Driver\ServerInfoAwareConnection;
1617
useDoctrine\DBAL\Platforms\SQLServer2008Platform;
1718

1819
/**
@@ -241,9 +242,30 @@ private function getMergeSql()
241242
"WHEN MATCHED THEN UPDATE SET$this->dataCol = :data,$this->timeCol = :time;";
242243
case'sqlite' ===$platform:
243244
return"INSERT OR REPLACE INTO$this->table ($this->idCol,$this->dataCol,$this->timeCol) VALUES (:id, :data, :time)";
244-
case'postgresql' ===$platform &&version_compare($this->con->getServerVersion(),'9.5','>='):
245+
case'postgresql' ===$platform &&version_compare($this->getServerVersion(),'9.5','>='):
245246
return"INSERT INTO$this->table ($this->idCol,$this->dataCol,$this->timeCol) VALUES (:id, :data, :time)".
246247
"ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol,$this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->timeCol)";
247248
}
248249
}
250+
251+
privatefunctiongetServerVersion()
252+
{
253+
$params =$this->con->getParams();
254+
255+
if (isset($params['serverVersion'])) {
256+
return$params['serverVersion'];// Explicit platform version requested (supersedes auto-detection), so we respect it.
257+
}
258+
259+
$wrappedConnection =$this->con->getWrappedConnection();
260+
261+
if ($wrappedConnectioninstanceof ServerInfoAwareConnection) {
262+
return$wrappedConnection->getServerVersion();
263+
}
264+
265+
if ($wrappedConnectioninstanceof \PDO) {// Support DBAL 2.4 by accessing it directly when using PDO PgSQL
266+
return$wrappedConnection->getAttribute(\PDO::ATTR_SERVER_VERSION);
267+
}
268+
269+
return'';// If we cannot guess the version, the empty string will mean we won't use the code for newer versions when doing version checks.
270+
}
249271
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp