Emails are sometimes sent in the wrong language
Platform: Nginx is affected, but easier to reproduce on Apache
Start from a default install, enable password reset
- With an french web browser, or after selecting the french language in the portal, use the reset password form to send a reset link to firstname.lastname@example.org
- mail subject is in french
- mail body is in french
- With an english web browser, or after selecting the english language, reset email@example.com password
If you are using apache, there is a very high probability that the mail will arrive with
- mail subject in english
- mail body in french
If you are using nginx, you probably need to retry a few times to see it!
The code that sends emails uses loadTemplate, which compiles HTML::Templates with
cache => 1 and uses a filter for translation
Apparently, the cache is stored after applying the filter, and not before :( which means that the next time the same PID processes your template, you will get whichever language was used when creating the HTML::Template cache
The simple solution is to simply disable HTML::Template caching when generating emails. This shouldn't hurt performance since emails are rare events compared to regular web page generation.