From 1858dee8d6583208fe56cb8ffdd724bf20ec46a6 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 14 Jul 2020 16:51:45 +1200 Subject: [PATCH] Remove hard coded charset. In thinking about the proposal here https://github.com/civicrm/civicrm-core/pull/13633/files#diff-c5e39924ad99ac88b48763a0d8fa246eR30 to switch to utf8mb4 I found that none of the places on the web that suggest functions like ours specifiy charset - eg. https://stackoverflow.com/questions/287105/mysql-strip-non-numeric-characters-to-compare When I look at the code it is iterating through the characters to find integers - which should be the same regardless of charset. So, I think we can simply remove it. : --- CRM/Contact/BAO/Contact.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index b540a8e4e1..b97aa37b12 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -27,12 +27,12 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { const DROP_STRIP_FUNCTION_43 = "DROP FUNCTION IF EXISTS civicrm_strip_non_numeric"; const CREATE_STRIP_FUNCTION_43 = " - CREATE FUNCTION civicrm_strip_non_numeric(input VARCHAR(255) CHARACTER SET utf8) - RETURNS VARCHAR(255) CHARACTER SET utf8 + CREATE FUNCTION civicrm_strip_non_numeric(input VARCHAR(255)) + RETURNS VARCHAR(255) DETERMINISTIC NO SQL BEGIN - DECLARE output VARCHAR(255) CHARACTER SET utf8 DEFAULT ''; + DECLARE output VARCHAR(255) DEFAULT ''; DECLARE iterator INT DEFAULT 1; WHILE iterator < (LENGTH(input) + 1) DO IF SUBSTRING(input, iterator, 1) IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') THEN -- 2.25.1