mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-46868 glossary / filter: performance, check modinfo sooner.
Since we need to check modinfo anyway, do that as soon as possible so we can get a performance win if there are no glossaries in the course.
This commit is contained in:
parent
e609e6cf02
commit
a6bbb92607
1 changed files with 8 additions and 2 deletions
|
@ -159,6 +159,14 @@ class concept_cache {
|
||||||
|
|
||||||
$courseid = (int)$courseid;
|
$courseid = (int)$courseid;
|
||||||
|
|
||||||
|
// Get info on any glossaries in this course.
|
||||||
|
$modinfo = get_fast_modinfo($courseid);
|
||||||
|
$cminfos = $modinfo->get_instances_of('glossary');
|
||||||
|
if (!$cminfos) {
|
||||||
|
// No glossaries in this course, so don't do any work.
|
||||||
|
return array(array(), array());
|
||||||
|
}
|
||||||
|
|
||||||
$cache = \cache::make('mod_glossary', 'concepts');
|
$cache = \cache::make('mod_glossary', 'concepts');
|
||||||
$data = $cache->get($courseid);
|
$data = $cache->get($courseid);
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
|
@ -201,8 +209,6 @@ class concept_cache {
|
||||||
$concepts = $allconcepts;
|
$concepts = $allconcepts;
|
||||||
|
|
||||||
// Verify access control to glossary instances.
|
// Verify access control to glossary instances.
|
||||||
$modinfo = get_fast_modinfo($courseid);
|
|
||||||
$cminfos = $modinfo->get_instances_of('glossary');
|
|
||||||
foreach ($concepts as $modid => $unused) {
|
foreach ($concepts as $modid => $unused) {
|
||||||
if (!isset($cminfos[$modid])) {
|
if (!isset($cminfos[$modid])) {
|
||||||
// This should not happen.
|
// This should not happen.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue