Skip to content

Commit d6d8b5e

Browse files
committed
EA-6357: Get rid of two email_address [WARN] messages
Ticket: https://sugarcrm.atlassian.net/browse/EA-6357 Tidbit generates EmailAddresses module records (12,000 by default). The invalid_email and opt_out fields are of type bool, so they pick up the default bool rule: ['range' => ['min' => 0, 'max' => 1]] — randomly 0 or 1 per record. Email addresses are not unique — with only ~100 last names from last_name_array, there are many records with the same email_address_caps (e.g. SMITH@EXAMPLE.COM) but different invalid_email values. e.g.: seed-Emadd-001: smith@example.com, invalid_email=0 seed-Emadd-472: smith@example.com, invalid_email=1 A Contact is linked via email_addr_bean_rel to seed-Emadd-472 (invalid_email=1). When Sugar saves the Contact (via UI, API, or post-Tidbit operations), Person::save() → SugarEmailAddress::handleLegacySave() → addAddress() → getEmailGUID() → getGuid() which queries email_addresses by email_address_caps and returns the first match: seed-Emadd-001 (invalid_email=0). The address now has email_address_id=seed-Emadd-001 (not in email_addr_bean_rel for this Contact) → $emailId=null → AddUpdateEmailAddress looks up by caps, gets seed-Emadd-001 with invalid_email=0 as $existingBean, but the boolean value passed is true (from seed-Emadd-472). didEmailAddressChange sees "0" != true → TRUE → logUpdateEmailProperties fires: [WARN] Invalid email status was updated during creating a new record. From 0 to 1 [WARN] Opt Out status was updated during creating a new record. From 0 to 0 ← strict !== type mismatch ("0" vs false)
1 parent 2231400 commit d6d8b5e

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

config/data/EmailAddresses.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
********************************************************************************/
3737

3838
$GLOBALS['dataTool']['EmailAddresses']['email_address'] = [
39-
'list' => 'last_name_array',
40-
'suffix' => "@example.com"
39+
'same' => 'id',
40+
'suffix' => "@example.com",
41+
'strReplace' => ['search' => "'", 'replace' => ''],
42+
'toLower' => true,
43+
'isQuoted' => true
4144
];
4245
$GLOBALS['dataTool']['EmailAddresses']['email_address_caps'] = ['same' => 'email_address', 'toUpper' => true];

src/DataTool.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,13 @@ public function handleType($typeData, $type, $field, bool $resetStatic = false):
538538
$baseValue = $this->truncateDataByLength($baseValue, (string) $GLOBALS['fieldData']['len']);
539539
}
540540

541+
if (!empty($typeData['strReplace'])) {
542+
$baseValue = str_replace(
543+
(string) $typeData['strReplace']['search'],
544+
(string) $typeData['strReplace']['replace'],
545+
(string) $baseValue);
546+
}
547+
541548
if ($isQuote || !empty($typeData['isQuoted'])) {
542549
$baseValue = "'" . @trim((string) $baseValue) . "'";
543550
}

0 commit comments

Comments
 (0)