diff options
author | Marcel Klehr <mklehr@gmx.net> | 2025-07-21 15:49:40 +0200 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2025-07-21 15:49:40 +0200 |
commit | 8589debf6de52849e01b01fe842b211dc1676db6 (patch) | |
tree | 68e47c2f75e78517efba431931ef9c69b82c582c | |
parent | 30fb9e3c5a91d8509f2c0c3299b51dd09069b45b (diff) | |
download | nextcloud-server-fix/oracle-db-connection.tar.gz nextcloud-server-fix/oracle-db-connection.zip |
fix(ConnectionFactory): Apply Oracle connection fix to primary and replica params as wellfix/oracle-db-connection
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; + } } |