}
/**
- * Used during case component enablement and during ugprade.
+ * Used during case component enablement and during upgrade.
*
* @return bool
*/
public static function createCaseViews() {
- $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$dao = new CRM_Core_DAO();
+ try {
+ $sql = self::createCaseViewsQuery('upcoming');
+ $dao->query($sql);
- $sql = self::createCaseViewsQuery('upcoming');
- $dao->query($sql);
- if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
- return FALSE;
- }
-
- // Above error doesn't get caught?
- $doublecheck = $dao->singleValueQuery("SELECT count(id) FROM civicrm_view_case_activity_upcoming");
- if (is_null($doublecheck)) {
- return FALSE;
- }
-
- $sql = self::createCaseViewsQuery('recent');
- $dao->query($sql);
- if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
- return FALSE;
+ $sql = self::createCaseViewsQuery('recent');
+ $dao->query($sql);
}
-
- // Above error doesn't get caught?
- $doublecheck = $dao->singleValueQuery("SELECT count(id) FROM civicrm_view_case_activity_recent");
- if (is_null($doublecheck)) {
+ catch (Exception $e) {
return FALSE;
}
if (\Civi::settings()->get('logging_no_trigger_permission')) {
return TRUE;
}
- // test for create view and trigger permissions and if allowed, add the option to go multilingual
- // and logging
- // I'm not sure why we use the getStaticProperty for an error, rather than checking for DB_Error
+ // test for create view and trigger permissions and if allowed, add the option to go multilingual and logging
$dao = new CRM_Core_DAO();
- if ($view) {
- $result = $dao->query('CREATE OR REPLACE VIEW civicrm_domain_view AS SELECT * FROM civicrm_domain');
- if (PEAR::getStaticProperty('DB_DataObject', 'lastError') || is_a($result, 'DB_Error')) {
- return FALSE;
- }
- }
-
- if ($trigger) {
- $result = $dao->query('CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EACH ROW BEGIN END');
- if (PEAR::getStaticProperty('DB_DataObject', 'lastError') || is_a($result, 'DB_Error')) {
- if ($view) {
- $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
- }
- return FALSE;
+ try {
+ if ($view) {
+ $dao->query('CREATE OR REPLACE VIEW civicrm_domain_view AS SELECT * FROM civicrm_domain');
+ $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
}
- $dao->query('DROP TRIGGER IF EXISTS civicrm_domain_trigger');
- if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
- if ($view) {
- $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
- }
- return FALSE;
+ if ($trigger) {
+ $dao->query('CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EACH ROW BEGIN END');
+ $dao->query('DROP TRIGGER IF EXISTS civicrm_domain_trigger');
}
}
-
- if ($view) {
- $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
- if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
- return FALSE;
- }
+ catch (Exception $e) {
+ return FALSE;
}
return TRUE;