From dc247e5232cb2d8e384c0acefa3f9e90fbaee78d Mon Sep 17 00:00:00 2001 From: fmarier Date: Thu, 14 May 2009 06:04:35 +0000 Subject: [PATCH] MDL-19179 cache superfluous queries when listing categories on front page --- course/lib.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 { -- 2.39.5