generateEmailData does not reliably restore the original language

Xon

Well-known member
Affected version
2.3.7
The generateEmailData function doesn't wrap a try/finally around the handling of the setLanguage calls, meaning if the code inside this method throws an exception the global language may have changed unexpectedly.

This matters as by default job.php will execute multiple jobs via runJobInternal which may have the underlying language unexpectedly change. Maybe runJobInternal should restore the language to whatever was at the start and clear any visitor object to guard against these leaks?

PHP:
protected function generateEmailData(User $user)
{
    $originalLanguage = \XF::language();
    \XF::setLanguage(\XF::app()->userLanguage($user));

...
    \XF::setLanguage($originalLanguage);

    return $instance;
}
 
Back
Top Bottom