MDL-69698 licenses: Do not cache the localised licenses fullnames
The localisation must happen only after loading the list of licenses from cache so that the name is displayed in the current user's preferred language, not in the language of the user who initiated the cache rebuild.
This commit is contained in:
+10
-7
@@ -227,21 +227,24 @@ class license_manager {
|
||||
$cache = \cache::make('core', 'license');
|
||||
$licenses = $cache->get('licenses');
|
||||
|
||||
if (empty($licenses)) {
|
||||
if ($licenses === false) {
|
||||
$licenses = [];
|
||||
$records = $DB->get_records_select('license', null, null, 'sortorder ASC');
|
||||
foreach ($records as $license) {
|
||||
// Interpret core license strings for internationalisation.
|
||||
if ($license->custom == self::CORE_LICENSE) {
|
||||
$license->fullname = get_string($license->shortname, 'license');
|
||||
} else {
|
||||
$license->fullname = format_string($license->fullname);
|
||||
}
|
||||
$licenses[$license->shortname] = $license;
|
||||
}
|
||||
$cache->set('licenses', $licenses);
|
||||
}
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
// Localise the license names.
|
||||
if ($license->custom == self::CORE_LICENSE) {
|
||||
$license->fullname = get_string($license->shortname, 'core_license');
|
||||
} else {
|
||||
$license->fullname = format_string($license->fullname);
|
||||
}
|
||||
}
|
||||
|
||||
return $licenses;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user