aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/config.sample.php6
-rw-r--r--lib/private/DB/ConnectionFactory.php9
2 files changed, 12 insertions, 3 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index e09b0904808..3fe70e8d783 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -112,9 +112,9 @@ $CONFIG = [
/**
* Your host server name, for example ``localhost``, ``hostname``,
- * ``hostname.example.com``, or the IP address. To specify a port use
- * ``hostname:####``; to specify a Unix socket use
- * ``/path/to/directory/containing/socket`` e.g. ``/run/postgresql/``.
+ * ``hostname.example.com``, or the IP address.
+ * To specify a port use ``hostname:####``, for IPv6 addresses use the URI notation ``[ip]:port``.
+ * To specify a Unix socket use ``/path/to/directory/containing/socket``, e.g. ``/run/postgresql/``.
*/
'dbhost' => '',
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php
index e868f18ec34..c7a558e5879 100644
--- a/lib/private/DB/ConnectionFactory.php
+++ b/lib/private/DB/ConnectionFactory.php
@@ -128,6 +128,15 @@ class ConnectionFactory {
$eventManager->addEventSubscriber(new SetTransactionIsolationLevel());
$additionalConnectionParams = array_merge($this->createConnectionParams(), $additionalConnectionParams);
switch ($normalizedType) {
+ case 'pgsql':
+ // pg_connect used by Doctrine DBAL does not support URI notation (enclosed in brackets)
+ $matches = [];
+ if (preg_match('/^\[([^\]]+)\]$/', $additionalConnectionParams['host'], $matches)) {
+ // Host variable carries a port or socket.
+ $additionalConnectionParams['host'] = $matches[1];
+ }
+ break;
+
case 'oci':
$eventManager->addEventSubscriber(new OracleSessionInit);
// the driverOptions are unused in dbal and need to be mapped to the parameters