Use mb_strtolower to compare translated strings
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 6 Apr 2023 22:24:52 +0000 (10:24 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 6 Apr 2023 22:24:52 +0000 (10:24 +1200)
CRM/Core/BAO/CustomQuery.php

index 621441bc76ebd80e06004b035ff364f0d6059f02..98d8d68bc0931afd9b4fd063355479bd9daaaab4 100644 (file)
@@ -223,7 +223,7 @@ class CRM_Core_BAO_CustomQuery {
             else {
               // fix $value here to escape sql injection attacks
               if (!is_array($value)) {
-                if ($field['data_type'] == 'String') {
+                if ($field['data_type'] === 'String') {
                   $value = CRM_Utils_Type::escape($value, 'String');
                 }
                 elseif ($value) {
@@ -242,7 +242,7 @@ class CRM_Core_BAO_CustomQuery {
                 foreach ($value as $key => $val) {
                   $value[$key] = str_replace(['[', ']', ','], ['\[', '\]', '[:comma:]'], $val);
                   $value[$key] = str_replace('|', '[:separator:]', $value[$key]);
-                  if ($field['data_type'] == 'String') {
+                  if ($field['data_type'] === 'String') {
                     $value[$key] = CRM_Utils_Type::escape($value[$key], 'String');
                   }
                   elseif ($value) {
@@ -281,12 +281,12 @@ class CRM_Core_BAO_CustomQuery {
 
           case 'Int':
             $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Integer');
-            $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['label'], 2 => $qillOp, 3 => $qillValue]);
+            $this->_qill[$grouping][] = ts('%1 %2 %3', [1 => $field['label'], 2 => $qillOp, 3 => $qillValue]);
             break;
 
           case 'Boolean':
             if (!is_array($value)) {
-              if (strtolower($value) == 'yes' || strtolower($value) == strtolower(ts('Yes'))) {
+              if (mb_strtolower($value) === 'yes' || mb_strtolower($value) === mb_strtolower(ts('Yes'))) {
                 $value = 1;
               }
               else {