diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 395552221ff78ab2dfef2ee48e3f90e3fb84acfc..0069666815b164a200af03cbcc65fd74bd11d3f3 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1922,9 +1922,9 @@ EOS; // 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}"; } } diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index bb7efcd0981ab1a0d787621f4a8a5f511a405c21..877be2dad162fafbe664af121c99e4476aee7881 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -165,6 +165,20 @@ AND TABLE_NAME LIKE 'log_civicrm_%' $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}"); + } + } } /** diff --git a/tests/phpunit/CRM/Core/DAOTest.php b/tests/phpunit/CRM/Core/DAOTest.php index d6eedd98fdf0be7145f4da5337c12df4b32f7887..d0bba05048b242def694214ab66b95b1a6e2462a 100644 --- a/tests/phpunit/CRM/Core/DAOTest.php +++ b/tests/phpunit/CRM/Core/DAOTest.php @@ -168,7 +168,7 @@ class CRM_Core_DAOTest extends CiviUnitTestCase { 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'), ); }