From: Ravish Nair Date: Fri, 27 Sep 2013 13:32:27 +0000 (+0530) Subject: -- CRM-13417 changes as per comment X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b0c27559462724f3ea130616bc8175d4381d8b90;p=civicrm-core.git -- CRM-13417 changes as per comment ---------------------------------------- * CRM-13417: Dedupe Rule Creation error trapping fails on length selections for substrings of numeric fields or out of range numbers for text fields http://issues.civicrm.org/jira/browse/CRM-13417 --- diff --git a/CRM/Contact/Form/DedupeRules.php b/CRM/Contact/Form/DedupeRules.php index ea8154b811..b74f88ca48 100644 --- a/CRM/Contact/Form/DedupeRules.php +++ b/CRM/Contact/Form/DedupeRules.php @@ -237,6 +237,8 @@ UPDATE civicrm_dedupe_rule_group $substrLenghts = array(); $tables = array(); + $daoObj = new CRM_Core_DAO(); + $database = $daoObj->database(); for ($count = 0; $count < self::RULES_COUNT; $count++) { if (!CRM_Utils_Array::value("where_$count", $values)) { continue; @@ -267,14 +269,12 @@ UPDATE civicrm_dedupe_rule_group } //CRM-13417 to avoid fatal error "Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys, 1089" - $daoObj = new CRM_Core_DAO(); - $database = $daoObj->database(); $schemaQuery = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{$database}' AND TABLE_NAME = '{$table}' AND COLUMN_NAME = '{$field}';"; $dao = CRM_Core_DAO::executeQuery($schemaQuery); - while ($dao->fetch()) { + if ($dao->fetch()) { // set the length to null for all the fields where prefix length is not supported. eg. int,tinyint,date,enum etc dataTypes. if ($dao->COLUMN_NAME == $field && !in_array($dao->DATA_TYPE, array('char', 'varchar', 'binary', 'varbinary', 'text', 'blob'))) { $length = NULL;