Skip to content

Commit 88859aa

Browse files
authored
Merge pull request #44461 from nextcloud/backport/44394/stable28
2 parents c4370b6 + 2cabc70 commit 88859aa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

config/config.sample.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@
112112

113113
/**
114114
* Your host server name, for example ``localhost``, ``hostname``,
115-
* ``hostname.example.com``, or the IP address. To specify a port use
116-
* ``hostname:####``; to specify a Unix socket use
117-
* ``/path/to/directory/containing/socket`` e.g. ``/run/postgresql/``.
115+
* ``hostname.example.com``, or the IP address.
116+
* To specify a port use ``hostname:####``, for IPv6 addresses use the URI notation ``[ip]:port``.
117+
* To specify a Unix socket use ``/path/to/directory/containing/socket``, e.g. ``/run/postgresql/``.
118118
*/
119119
'dbhost' => '',
120120

lib/private/DB/ConnectionFactory.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function getConnection($type, $additionalConnectionParams) {
132132
$eventManager->addEventSubscriber(
133133
new SQLSessionInit("SET SESSION AUTOCOMMIT=1"));
134134
break;
135+
135136
case 'oci':
136137
$eventManager->addEventSubscriber(new OracleSessionInit);
137138
// the driverOptions are unused in dbal and need to be mapped to the parameters
@@ -151,6 +152,15 @@ public function getConnection($type, $additionalConnectionParams) {
151152
unset($additionalConnectionParams['host']);
152153
break;
153154

155+
case 'pgsql':
156+
// pg_connect used by Doctrine DBAL does not support URI notation (enclosed in brackets)
157+
$matches = [];
158+
if (preg_match('/^\[([^\]]+)\]$/', $additionalConnectionParams['host'], $matches)) {
159+
// Host variable carries a port or socket.
160+
$additionalConnectionParams['host'] = $matches[1];
161+
}
162+
break;
163+
154164
case 'sqlite3':
155165
$journalMode = $additionalConnectionParams['sqlite.journal_mode'];
156166
$additionalConnectionParams['platform'] = new OCSqlitePlatform();

0 commit comments

Comments
 (0)