Skip to content

Commit

Permalink
Use CRM_Utils_SQL::connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Jan 31, 2025
1 parent b616b4e commit f8717af
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CRM/Utils/System/Backdrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ protected function getUsersTableName() {
public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
$config = CRM_Core_Config::singleton();

$ufDSN = CRM_Utils_SQL::autoSwitchDSN($config->userFrameworkDSN);
$ufDSN = $config->userFrameworkDSN;
try {
$dbBackdrop = DB::connect($ufDSN);
$dbBackdrop = CRM_Utils_SQL::connect($ufDSN);
}
catch (Exception $e) {
throw new CRM_Core_Exception("Cannot connect to Backdrop database via $ufDSN, " . $e->getMessage());
Expand Down
5 changes: 3 additions & 2 deletions CRM/Utils/System/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,10 @@ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realP

$config = CRM_Core_Config::singleton();

$ufDSN = CRM_Utils_SQL::autoSwitchDSN($config->userFrameworkDSN);
$ufDSN = $config->userFrameworkDSN;

try {
$dbDrupal = DB::connect($ufDSN);
$dbDrupal = CRM_Utils_SQL::connect($ufDSN);
}
catch (Exception $e) {
throw new CRM_Core_Exception("Cannot connect to drupal db via $ufDSN, " . $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion ext/standaloneusers/Civi/Standalone/SessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function gc($max_lifetime): int {
* @return bool
*/
public function open($path, $name): bool {
$this->db = DB::connect(\CRM_Core_Config::singleton()->dsn);
$this->db = \CRM_Utils_SQL::connect(\CRM_Core_Config::singleton()->dsn);
$this->db->autoCommit(FALSE);

return TRUE;
Expand Down
3 changes: 1 addition & 2 deletions tests/phpunit/api/v3/SyntaxConformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ public static function toBeSkipped_getSqlOperators() {
// Re:^^^ => the failure was probably correct behavior, and test is now fixed, but yeah 5.5 is deprecated, and don't care enough to verify.
// Test data providers should be able to run in pre-boot environment, so we connect directly to SQL server.
require_once 'DB.php';
$dsn = CRM_Utils_SQL::autoSwitchDSN(CIVICRM_DSN);
$db = DB::connect($dsn);
$db = CRM_Utils_SQL::connect(CIVICRM_DSN);
if ($db->connection instanceof mysqli && $db->connection->server_version < 50600) {
$entitiesWithout[] = 'Dedupe';
}
Expand Down

0 comments on commit f8717af

Please sign in to comment.