I don't know what to say, sorry.Quote from Nao on September 21st, 2013, 01:35 AM How about triggering scheduled tasks only if the current user's language is the default..? Then at least we can avoid what happened last time.
I think that it would be best to test for scheduled task triggers only if the current visitor is using the default forum language; otherwise, we'll be risking what happened the other day, when everyone received an e-mail in French...
And frankly, I don't think it's realistic to expect the scheduler to 'know' what language files need to be reloaded specifically for this task.
Of course, I could 'quite simply' do some magic trick to loadLanguage...
function loadLanguage($template_name, $lang = '', $fatal = true, $force_reload = false, $fallback = false, $force_reload_all = false)
{
global $theme, $context, $settings, $boarddir, $db_show_debug, $txt, $helptxt, $cachedir;
static $already_loaded = array(), $folder_date = array();
if ($force_reload_all)
{
loadLanguage(array_keys($already_loaded), $lang, $fatal, true, $fallback);
return '';
}
There you go, this adds a trigger to force a mass-reload of all existing language files loaded so far.
Of course, that's going to be relatively expensive, but if we don't have more than a couple of active language files, it's just a matter of gathering all users that are on the same language as the current user, then send the e-mails, then gather the other users by language, and for them, call $force_reload_all, and send the e-mails to them. Then, restore $txt (which, of course, we'll have saved in the first place.)
Dunno which solution is the best, really... What do you think of this function hack, though?