@@ -133,21 +133,9 @@ public function getConnection(string $type, array $additionalConnectionParams):
133133
134134 case 'oci ' :
135135 $ eventManager ->addEventSubscriber (new OracleSessionInit );
136- // the driverOptions are unused in dbal and need to be mapped to the parameters
137- if (isset ($ connectionParams ['driverOptions ' ])) {
138- $ connectionParams = array_merge ($ connectionParams , $ connectionParams ['driverOptions ' ]);
139- }
140- $ host = $ connectionParams ['host ' ];
141- $ port = $ connectionParams ['port ' ] ?? null ;
142- $ dbName = $ connectionParams ['dbname ' ];
143-
144- // we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string
145- if ($ host === '' ) {
146- $ connectionParams ['dbname ' ] = $ dbName ; // use dbname as easy connect name
147- } else {
148- $ connectionParams ['dbname ' ] = '// ' . $ host . (!empty ($ port ) ? ": {$ port }" : "" ) . '/ ' . $ dbName ;
149- }
150- unset($ connectionParams ['host ' ]);
136+ $ connectionParams = $ this ->forceConnectionStringOracle ($ connectionParams );
137+ $ connectionParams ['primary ' ] = $ this ->forceConnectionStringOracle ($ connectionParams ['primary ' ]);
138+ $ connectionParams ['replica ' ] = array_map ([$ this , 'forceConnectionStringOracle ' ], $ connectionParams ['replica ' ]);
151139 break ;
152140
153141 case 'sqlite3 ' :
@@ -264,4 +252,24 @@ protected function splitHostFromPortAndSocket($host): array {
264252
265253 return $ params ;
266254 }
255+
256+ protected function forceConnectionStringOracle (array $ connectionParams ): array {
257+ // the driverOptions are unused in dbal and need to be mapped to the parameters
258+ if (isset ($ connectionParams ['driverOptions ' ])) {
259+ $ connectionParams = array_merge ($ connectionParams , $ connectionParams ['driverOptions ' ]);
260+ }
261+ $ host = $ connectionParams ['host ' ];
262+ $ port = $ connectionParams ['port ' ] ?? null ;
263+ $ dbName = $ connectionParams ['dbname ' ];
264+
265+ // we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string
266+ if ($ host === '' ) {
267+ $ connectionParams ['dbname ' ] = $ dbName ; // use dbname as easy connect name
268+ } else {
269+ $ connectionParams ['dbname ' ] = '// ' . $ host . (!empty ($ port ) ? ": {$ port }" : '' ) . '/ ' . $ dbName ;
270+ }
271+ unset($ connectionParams ['host ' ]);
272+
273+ return $ connectionParams ;
274+ }
267275}
0 commit comments