MDL-41114 Speeding up course listings on large sites

- function coursecat::make_categories_list() does not use retrieved contexts and has to query them again.
- /course/manage.php uses field coursecat:: that was not fetched when retrieving the course category children.
This commit is contained in:
Marina Glancy
2013-08-11 21:58:12 +10:00
parent 50ff861263
commit e4008e9db5
+2 -1
View File
@@ -48,7 +48,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
'descriptionformat' => null, // not cached
'parent' => array('pa', 0),
'sortorder' => array('so', 0),
'coursecount' => null, // not cached
'coursecount' => array('cc', 0),
'visible' => array('vi', 1),
'visibleold' => null, // not cached
'timemodified' => null, // not cached
@@ -1896,6 +1896,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
foreach ($rs as $record) {
// If the category's parent is not visible to the user, it is not visible as well.
if (!$record->parent || isset($baselist[$record->parent])) {
context_helper::preload_from_record($record);
$context = context_coursecat::instance($record->id);
if (!$record->visible && !has_capability('moodle/category:viewhiddencategories', $context)) {
// No cap to view category, added to neither $baselist nor $thislist