Compare commits

..

2 Commits

Author SHA1 Message Date
Steve Boyd
dc76ac2877
Merge d7c4b0c420 into 3eb61e353f 2024-09-27 02:59:59 +00:00
Steve Boyd
d7c4b0c420 FIX Ensure primary connection is updated with temporary database 2024-09-27 14:59:48 +12:00

View File

@ -625,9 +625,14 @@ class TestSessionEnvironment
private function connectToDB(array $databaseConfig): void
{
// Ensure we connect the primary connection and not a replica
// which can happen if we use the default value of DB::CONN_DYNAMIC
// and there is a replica database configured
DB::connect($databaseConfig, DB::CONN_PRIMARY);
if (method_exists(DB::class, 'hasConfig')) {
// CMS 5.4+ - ensure we connect the primary connection and not a replica
// which can happen if we use the default value of DB::CONN_DYNAMIC
// and there is a replica database configured
DB::connect($databaseConfig, DB::CONN_PRIMARY);
} else {
// CMS 5.3 and below do not support replica connections, use 'default' connection
DB::connect($databaseConfig);
}
}
}