From: fmarier Date: Thu, 14 May 2009 06:04:35 +0000 (+0000) Subject: MDL-19179 cache superfluous queries when listing categories on front page X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=dc247e5232cb2d8e384c0acefa3f9e90fbaee78d;p=moodle.git MDL-19179 cache superfluous queries when listing categories on front page --- diff --git a/course/lib.php b/course/lib.php index aff3060f33..b74917544f 100644 --- a/course/lib.php +++ b/course/lib.php @@ -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 = ''; } else {