mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 14:50:17 -04:00
fix(ConnectionFactory): Apply Oracle connection fix to primary and replica params as well
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
30fb9e3c5a
commit
8589debf6d
1 changed files with 23 additions and 15 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue