I took a look at the git blame for current_language() to see how it reached its current form, and why we don't just cache the result on the first hit.
Apparently the problem is that current_language() may be called for the first time at any point during the page load process, including as early as the sanity check. If that happens, then $USER or $SESSION may not be filled in yet, and consequently the user's language preference won't show up. I know that in theory helpfiles shouldn't be loaded until well after the $USER and $SESSION objects are loaded, but given that current_language() is rather sensitive and it already caches all its data, I'm not sure we should go cacheing the language in other functions. I think maybe the best approach here would instead be to try to make current_language() run more quickly. Perhaps once all the possible language sources are filled in, it can short-circuit past all of its if- thens and return more quickly? -- You received this bug notification because you are a member of Mahara Contributors, which is subscribed to Mahara. Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it! https://bugs.launchpad.net/bugs/1523310 Title: Avoid calling current_language() for each of the help icons on a page Status in Mahara: New Bug description: As the language can't change part way throuh page load we can set the $lang variable in get_helpfile_location() to be static To manage notifications about this bug go to: https://bugs.launchpad.net/mahara/+bug/1523310/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~mahara-contributors Post to : [email protected] Unsubscribe : https://launchpad.net/~mahara-contributors More help : https://help.launchpad.net/ListHelp

