]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19179 cache superfluous queries when listing categories on front page
authorfmarier <fmarier>
Thu, 14 May 2009 06:04:35 +0000 (06:04 +0000)
committerfmarier <fmarier>
Thu, 14 May 2009 06:04:35 +0000 (06:04 +0000)
course/lib.php

index aff3060f331241b96a5a340f6e561e58538ba6fd..b74917544fd3c55a56813b465243bda22a1d0ef9 100644 (file)
@@ -2067,7 +2067,12 @@ function print_category_info($category, $depth, $showcourses = false) {
 
     $catlinkcss = $category->visible ? '' : ' class="dimmed" ';
 
-    $coursecount = $DB->count_records('course') <= FRONTPAGECOURSELIMIT;
+    static $coursecount = null;
+    if (null === $coursecount) {
+        // only need to check this once
+        $coursecount = $DB->count_records('course') <= FRONTPAGECOURSELIMIT;
+    }
+
     if ($showcourses and $coursecount) {
         $catimage = '<img src="'.$CFG->pixpath.'/i/course.gif" alt="" />';
     } else {