From 6527b097e8ac7b386d68d4949f00427c9c6dbaa9 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 18 Aug 2014 13:43:48 +0100 Subject: [PATCH] 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. --- mod/glossary/classes/local/concept_cache.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mod/glossary/classes/local/concept_cache.php b/mod/glossary/classes/local/concept_cache.php index a7f42b9be5a..cd5adc8046b 100644 --- a/mod/glossary/classes/local/concept_cache.php +++ b/mod/glossary/classes/local/concept_cache.php @@ -159,6 +159,14 @@ class concept_cache { $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'); $data = $cache->get($courseid); if (is_array($data)) { @@ -201,8 +209,6 @@ class concept_cache { $concepts = $allconcepts; // Verify access control to glossary instances. - $modinfo = get_fast_modinfo($courseid); - $cminfos = $modinfo->get_instances_of('glossary'); foreach ($concepts as $modid => $unused) { if (!isset($cminfos[$modid])) { // This should not happen.