Segment email translations are broadcast independently, sending the translated version to contacts regardless of preferred locale
| Q | A |
|---|---|
| Mautic version | 7.0.x (also verified by code inspection on current 7.1.0-rc head) |
| PHP version | 8.3 |
Summary
When a segment email has a translation, the mautic:broadcasts:send command processes the translation child as its own independent broadcast. Because of how the per-broadcast language map is built, the child broadcast sends the translated version to every pending contact in its batch, regardless of preferred_locale (even contacts whose locale matches the parent's language). Which language a contact receives ends up being a race between the two broadcast jobs, not a function of their locale.
The documented behaviour is: "if a contact has a preferred language set, they receive the translated version in their preferred language if it exists, otherwise they receive the parent in the default language."
Steps to reproduce
- Create segment email A (language
en), assign segment S, publish. - Create segment email B as a translation of A (language
pt_PT), publish. (Saving forces B to inherit A's segments —EmailModel::saveEntity().) - Ensure S is larger than the broadcast batch limit, so neither broadcast drains the segment in one run.
- Let the
mautic:broadcasts:sendcron run.
Expected: contacts with preferred_locale starting with pt receive B; everyone else (including contacts with an empty preferred_locale) receives A.
Actual: contacts processed under A's broadcast behave as expected, but contacts processed under B's broadcast all receive B — including contacts with an empty preferred_locale and even contacts with preferred_locale = en. On a real send to ~24k contacts (few of which had preferred_locale set), 19,241 received the pt_PT translation and only 4,667 received the en parent.
No duplicates occur (the pending query excludes contacts with a stat on any related translation id), which hides the problem: every contact gets exactly one email, just in an arbitrary language.
Root cause (3 interacting pieces)
EmailRepository::getPublishedBroadcastsQuery()(app/bundles/EmailBundle/Entity/EmailRepository.php) only filters on published-by-date +emailType = 'list'. It does not exclude emails that have atranslationParent, so the translation child is picked up as a separate broadcast targeting the same segments.EmailModel::sendEmail()(app/bundles/EmailBundle/Model/EmailModel.php, "Group contacts by preferred locale" block): contacts with an emptypreferred_localefall through to$details['languages']['default'], anddefaultis the id of the email currently being broadcast (getEmailSettings()). Under the child's broadcast, "default" is the translation, not the parent.getEmailSettings()builds the language map from$email->getTranslations(true), which returns only the children of the translation parent (TranslationEntityTrait::getTranslations()). When the email being sent is the child, the resulting map is['default' => childId, '<childLocale>' => childId]— the parent's language is absent, so even contacts whosepreferred_localematches the parent's language receive the child.
Suggested fix
Exclude translation children from the broadcast query, e.g. in getPublishedBroadcastsQuery():
$expr->add(
$qb->expr()->isNull($this->getTableAlias().'.translationParent')
);With only the parent processed as a broadcast, the existing locale grouping in sendEmail() routes translations correctly (matching locale → child, everything else → parent), which matches the documented behaviour. The auto-unpublish check ("no more pending contacts") would also then apply to the family as a whole via the parent.
Related (but distinct) reports: #6395 (campaigns don't auto-select translations), #8629 / #11586 (marketing-email dedupe not evaluating translations).
Care about this issue? Want to get it resolved sooner? If you are a member of Mautic, you can add some funds to the Bounties Project so that the person who completes this task can claim those funds once it is merged by a member of the core team! Read the docs here.
Source: mautic/mautic