Skip to content

Commit

Permalink
Merge branch 'MDL-69698-master-licensecache' of git://github.com/mudr…
Browse files Browse the repository at this point in the history
…d8mz/moodle into master
  • Loading branch information
stronk7 committed Sep 24, 2020
2 parents b583ce1 + be2015a commit 98aadb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/db/caches.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
// Cache for licenses.
'license' => [
'mode' => cache_store::MODE_APPLICATION,
'simplekeys' => false,
'simpledata' => false
'simplekeys' => true,
'simpledata' => false,
],
);
17 changes: 10 additions & 7 deletions lib/licenselib.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,24 @@ static public function get_licenses() {
$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;
}

Expand Down

0 comments on commit 98aadb0

Please sign in to comment.