Skip to content

Commit 40d80a3

Browse files
marcelklehrbackportbot[bot]
authored andcommitted
fix(ConnectionFactory): Apply Oracle connection fix to primary and replica params as well
Signed-off-by: Marcel Klehr <[email protected]> [skip ci]
1 parent 7543679 commit 40d80a3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/private/DB/ConnectionFactory.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,24 @@ protected function splitHostFromPortAndSocket($host): array {
264264

265265
return $params;
266266
}
267+
268+
protected function forceConnectionStringOracle(array $connectionParams): array {
269+
// the driverOptions are unused in dbal and need to be mapped to the parameters
270+
if (isset($connectionParams['driverOptions'])) {
271+
$connectionParams = array_merge($connectionParams, $connectionParams['driverOptions']);
272+
}
273+
$host = $connectionParams['host'];
274+
$port = $connectionParams['port'] ?? null;
275+
$dbName = $connectionParams['dbname'];
276+
277+
// we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string
278+
if ($host === '') {
279+
$connectionParams['dbname'] = $dbName; // use dbname as easy connect name
280+
} else {
281+
$connectionParams['dbname'] = '//' . $host . (!empty($port) ? ":{$port}" : '') . '/' . $dbName;
282+
}
283+
unset($connectionParams['host']);
284+
285+
return $connectionParams;
286+
}
267287
}

0 commit comments

Comments
 (0)