Skip to content

Commit 1dd1cb5

Browse files
committed
Merge branch '3.0' into 3.1
* 3.0: Fix PHP 7.1 related failures [VarDumper] Fix for 7.1 fixed CS Added class existence check if is_subclass_of() fails in compiler passes Fix the DBAL session handler version check for Postgresql
2 parents b9ff959 + 7734d6d commit 1dd1cb5

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

HttpFoundation/DbalSessionHandler.php

Lines changed: 26 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,33 @@ 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+
// Explicit platform version requested (supersedes auto-detection), so we respect it.
256+
if (isset($params['serverVersion'])) {
257+
return $params['serverVersion'];
258+
}
259+
260+
$wrappedConnection = $this->con->getWrappedConnection();
261+
262+
if ($wrappedConnection instanceof ServerInfoAwareConnection) {
263+
return $wrappedConnection->getServerVersion();
264+
}
265+
266+
// Support DBAL 2.4 by accessing it directly when using PDO PgSQL
267+
if ($wrappedConnection instanceof \PDO) {
268+
return $wrappedConnection->getAttribute(\PDO::ATTR_SERVER_VERSION);
269+
}
270+
271+
// If we cannot guess the version, the empty string will mean we won't use the code for newer versions when doing version checks.
272+
return '';
273+
}
249274
}

0 commit comments

Comments
 (0)