// the string is longer than the length and we need a uniq string
// for the same tablename we need the same uniq string everytime
// hence we use md5 on the string, which is not random
- // we'll append 16 characters to the end of the tableName
- $md5string = substr(md5($string), 0, 16);
- return substr($string, 0, $length - 17) . "_{$md5string}";
+ // we'll append 8 characters to the end of the tableName
+ $md5string = substr(md5($string), 0, 8);
+ return substr($string, 0, $length - 8) . "_{$md5string}";
}
}
$dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_update");
$dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_delete");
}
+
+ // now lets also be safe and drop all triggers that start with
+ // civicrm_ if we are dropping all triggers
+ // we need to do this to capture all the leftover triggers since
+ // we did the shortening trigger name for CRM-11794
+ if ($tableName === NULL) {
+ $triggers = $dao->executeQuery("SHOW TRIGGERS LIKE 'civicrm_%'");
+
+ while ($triggers->fetch()) {
+ // note that drop trigger has a wierd syntax and hence we do not
+ // send the trigger name as a string (i.e. its not quoted
+ $dao->executeQuery("DROP TRIGGER IF EXISTS {$triggers->Trigger}");
+ }
+ }
}
/**
array('this is an even longer string which is exactly 60 character', 60, TRUE , 'this is an even longer string which is exactly 60 character'),
array('this is an even longer string which is a bit more than 60 character', 60, FALSE, 'this is an even longer string which is a bit more than 60 ch'),
- array('this is an even longer string which is a bit more than 60 character', 60, TRUE , 'this is an even longer string which is a bi_c1cbd5198187eb96'),
+ array('this is an even longer string which is a bit more than 60 character', 60, TRUE , 'this is an even longer string which is a bit more th_c1cbd519'),
);
}