Skip to content
Snippets Groups Projects
Commit 66ed0bee authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

fixes for CRM-13587, due to mysql limitations drop and rebuild trigger

----------------------------------------
* CRM-13587: Can't update table 'civicrm_contact' in stored function/trigger because it is already used by statement which invoked this stored function/trigger
  http://issues.civicrm.org/jira/browse/CRM-13587
parent 879db7b0
Branches
Tags
No related merge requests found
......@@ -602,8 +602,6 @@ WHERE name = %1";
$contactType->id = CRM_Utils_Array::value('id', $params);
$contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
$contactType->save();
if ($contactType->find(TRUE)) {
$contactName = $contactType->name;
......@@ -812,14 +810,16 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause);
* @return void
* @access public
*/
public static function deleteCustomRowsOfSubtype($gID, $subtypes = array(
)) {
public static function deleteCustomRowsOfSubtype($gID, $subtypes = array()) {
if (!$gID or empty($subtypes)) {
return FALSE;
}
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $gID, 'table_name');
// drop triggers CRM-13587
CRM_Core_DAO::dropTriggers($tableName);
$subtypeClause = array();
foreach ($subtypes as $subtype) {
$subtype = CRM_Utils_Type::escape($subtype, 'String');
......@@ -831,7 +831,11 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause);
FROM {$tableName} custom
INNER JOIN civicrm_contact ON civicrm_contact.id = custom.entity_id
WHERE ($subtypeClause)";
return CRM_Core_DAO::singleValueQuery($query);
CRM_Core_DAO::singleValueQuery($query);
// rebuild triggers CRM-13587
CRM_Core_DAO::triggerRebuild($tableName);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment