diff options
author | Marcel Klehr <mklehr@gmx.net> | 2025-07-21 15:49:40 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2025-07-28 06:14:08 +0000 |
commit | 8173f5eb4457709007c6fca09d645385d6241117 (patch) | |
tree | 455da0a5de6f6b827f1452cc2de42002c8e8a171 | |
parent | d6468653e4e7241f5e9e6e38b35869a716b31d4f (diff) | |
download | nextcloud-server-backport/54027/stable31.tar.gz nextcloud-server-backport/54027/stable31.zip |
fix(ConnectionFactory): Apply Oracle connection fix to primary and replica params as wellbackport/54027/stable31
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
-rw-r--r-- | lib/private/DB/ConnectionFactory.php | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index 4d286cb3068..d9b80b81992 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -121,21 +121,9 @@ class ConnectionFactory { case 'oci': $eventManager->addEventSubscriber(new OracleSessionInit); - // the driverOptions are unused in dbal and need to be mapped to the parameters - if (isset($connectionParams['driverOptions'])) { - $connectionParams = array_merge($connectionParams, $connectionParams['driverOptions']); - } - $host = $connectionParams['host']; - $port = $connectionParams['port'] ?? null; - $dbName = $connectionParams['dbname']; - - // we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string - if ($host === '') { - $connectionParams['dbname'] = $dbName; // use dbname as easy connect name - } else { - $connectionParams['dbname'] = '//' . $host . (!empty($port) ? ":{$port}" : '') . '/' . $dbName; - } - unset($connectionParams['host']); + $connectionParams = $this->forceConnectionStringOracle($connectionParams); + $connectionParams['primary'] = $this->forceConnectionStringOracle($connectionParams['primary']); + $connectionParams['replica'] = array_map([$this, 'forceConnectionStringOracle'], $connectionParams['replica']); break; case 'sqlite3': @@ -265,4 +253,24 @@ class ConnectionFactory { return $params; } + + protected function forceConnectionStringOracle(array $connectionParams): array { + // the driverOptions are unused in dbal and need to be mapped to the parameters + if (isset($connectionParams['driverOptions'])) { + $connectionParams = array_merge($connectionParams, $connectionParams['driverOptions']); + } + $host = $connectionParams['host']; + $port = $connectionParams['port'] ?? null; + $dbName = $connectionParams['dbname']; + + // we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string + if ($host === '') { + $connectionParams['dbname'] = $dbName; // use dbname as easy connect name + } else { + $connectionParams['dbname'] = '//' . $host . (!empty($port) ? ":{$port}" : '') . '/' . $dbName; + } + unset($connectionParams['host']); + + return $connectionParams; + } } |