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

Appearance settings

Commit 28029a2

Browse filesBrowse files
committed
bug #19369 Fix the DBAL session handler version check for Postgresql (stof)
This PR was merged into the 2.7 branch. Discussion ---------- Fix the DBAL session handler version check for Postgresql | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | n/a | License | MIT | Doc PR | n/a #19048 broken the DBAL session handler when using Postgresql by using method which does not exist on the main DBAL Connection class. Commits ------- e98c584 Fix the DBAL session handler version check for Postgresql
2 parents 4590759 + e98c584 commit 28029a2
Copy full SHA for 28029a2

File tree

1 file changed

+23
-1
lines changed
Filter options

1 file changed

+23
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\DBAL\Connection;
1515
use Doctrine\DBAL\Driver\DriverException;
16+
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
1617
use Doctrine\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+
private function getServerVersion()
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 ($wrappedConnection instanceof ServerInfoAwareConnection) {
262+
return $wrappedConnection->getServerVersion();
263+
}
264+
265+
if ($wrappedConnection instanceof \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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.