CRM-17860 - loadCaseSampleData - Don't muck with connections/transactions
authorTim Otten <totten@civicrm.org>
Sat, 23 Jan 2016 01:41:50 +0000 (17:41 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 2 Feb 2016 04:56:23 +0000 (21:56 -0700)
CRM/Admin/Form/Setting/Component.php
CRM/Case/Info.php

index cdcf59be823fda913654ae2b7c452f4a225021d9..092a86c523410c26c2d32c4bd6bf56bb5538022f 100644 (file)
@@ -119,11 +119,9 @@ class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting {
    * @param string $fileName
    * @param bool $lineMode
    */
-  public static function loadCaseSampleData($dsn, $fileName, $lineMode = FALSE) {
-    $db = &DB::connect($dsn);
-    if (PEAR::isError($db)) {
-      die("Cannot open $dsn: " . $db->getMessage());
-    }
+  public static function loadCaseSampleData($fileName, $lineMode = FALSE) {
+    $dao = new CRM_Core_DAO();
+    $db = $dao->getDatabaseConnection();
 
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
index 6117e85a187f266eb981877005b5c016bd230d3c..89669c2cb6d191d0d4e45af5695eafec09a6a92f 100644 (file)
@@ -249,8 +249,7 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
       (!$oldValue || !in_array('CiviCase', $oldValue))
     ) {
       $pathToCaseSampleTpl = __DIR__ . '/xml/configuration.sample/';
-      $config = CRM_Core_Config::singleton();
-      CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $pathToCaseSampleTpl . 'case_sample.mysql.tpl');
+      CRM_Admin_Form_Setting_Component::loadCaseSampleData($pathToCaseSampleTpl . 'case_sample.mysql.tpl');
       if (!CRM_Case_BAO_Case::createCaseViews()) {
         $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
         CRM_Core_Error::fatal($msg);