From 164b0d3b762855b2f72ccaca6c255998b1fdfd44 Mon Sep 17 00:00:00 2001 From: Ludo444 Date: Mon, 7 Oct 2019 10:38:36 +0300 Subject: [PATCH] Fix for email addresses with accented and non-ASCII characters during IMAP sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Occasionally during IMAP sync the email address is received with foreign non-ASCII characters which are in PHP treated separately from purely ASCII ones. This later creates SQL Unique violation as it is flushed into database, where it's treated identically as ASCII characters. For example: - émáil@example.com - email@example.com is added to addresses under different key during IMAP sync. However during flush to database both above addresses are treated as 'email@example.com', so it triggers MySQL error with `oro_email_address_uq` constraint. This converts it to use only ASCII characters for email. --- .../Bundle/EmailBundle/Builder/EmailEntityBatchProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Oro/Bundle/EmailBundle/Builder/EmailEntityBatchProcessor.php b/src/Oro/Bundle/EmailBundle/Builder/EmailEntityBatchProcessor.php index 433de5bdcab..c07fdab000b 100644 --- a/src/Oro/Bundle/EmailBundle/Builder/EmailEntityBatchProcessor.php +++ b/src/Oro/Bundle/EmailBundle/Builder/EmailEntityBatchProcessor.php @@ -90,7 +90,7 @@ public function addEmailUser(EmailUser $obj) */ public function addAddress(EmailAddress $obj) { - $key = strtolower($obj->getEmail()); + $key = transliterator_transliterate('Any-Latin;Latin-ASCII;Lower;', $obj->getEmail()); if (isset($this->addresses[$key])) { throw new \LogicException(sprintf('The email address "%s" already exists in the batch.', $obj->getEmail())); }