Skip to content

Commit

Permalink
Replace hard-coded utf8_bin with binary in-use collation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich Lott / Artful Robot committed Oct 12, 2020
1 parent 6e2d84a commit 7dd3301
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CRM/Contact/BAO/RelationshipCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class CRM_Contact_BAO_RelationshipCache extends CRM_Contact_DAO_RelationshipCach
*/
public static function onHookTriggerInfo($e) {
$relUpdates = self::createInsertUpdateQueries();
// Use utf8mb4_bin or utf8_bin, depending on what's in use.
$collation = preg_replace('/^(utf8(?:mb4)?)_.*$/', '$1_bin', CRM_Core_BAO_SchemaHandler::getInUseCollation());

foreach ($relUpdates as $relUpdate) {
/**
* This trigger runs whenever a "civicrm_relationship" record is inserted or updated.
Expand Down Expand Up @@ -98,7 +101,7 @@ public static function onHookTriggerInfo($e) {

// Condition
implode(' OR ', array_map(function ($col) {
return "(OLD.$col != NEW.$col COLLATE utf8_bin)";
return "(OLD.$col != NEW.$col COLLATE $collation)";
}, self::$relTypeWatchFields)),

// Action
Expand Down

0 comments on commit 7dd3301

Please sign in to comment.