Compare commits

..

2 Commits

View File

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