fix: [over-correlations] weren't truly case insensitive, causing potential issues matching and entering values

- wrapped adding a new value in a try catch, no need to make synchronisations fail over this
- added case insensitive change to values on entry (table should be all lower-case)
- added update script to lowercase existing values
pull/9090/head
iglocska 2023-05-22 11:26:05 +02:00
parent b82a151c7b
commit 2252d16c91
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 14 additions and 6 deletions

View File

@ -84,7 +84,7 @@ class AppModel extends Model
87 => false, 88 => false, 89 => false, 90 => false, 91 => false, 92 => false,
93 => false, 94 => false, 95 => true, 96 => false, 97 => true, 98 => false,
99 => false, 100 => false, 101 => false, 102 => false, 103 => false, 104 => false,
105 => false, 106 => false, 107 => false, 108 => false,
105 => false, 106 => false, 107 => false, 108 => false, 109 => false
);
const ADVANCED_UPDATES_DESCRIPTION = array(
@ -1950,6 +1950,9 @@ class AppModel extends Model
case 108:
$sqlArray[] = "ALTER TABLE `workflows` MODIFY `data` LONGTEXT;";
break;
case 109:
$sqlArray[] = "UPDATE `over_correlating_values` SET `value` = LOWER(`value`) COLLATE utf8mb4_unicode_ci;";
break;
case 'fixNonEmptySharingGroupID':
$sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';
$sqlArray[] = 'UPDATE `attributes` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';

View File

@ -10,6 +10,7 @@ class OverCorrelatingValue extends AppModel
public static function truncate(string $value): string
{
$value = mb_strtolower($value);
return mb_substr($value, 0, 191);
}
@ -45,11 +46,15 @@ class OverCorrelatingValue extends AppModel
if (!$this->isBlocked($value)) {
$value = self::truncate($value);
$this->create();
$this->save([
'value' => $value,
'occurrence' => 0
]);
$this->blockedValues[$value] = true;
try {
$this->save([
'value' => mb_strtolower($value),
'occurrence' => 0
]);
$this->blockedValues[$value] = true;
} catch (Exception $e) {
//most likely we ran into an issue with capitalisation, there's no reason to break the process for this
}
}
}