if ($rv !== false) {
return $rv;
}
- // We did not find the entry in cache but it also can mean that tree is not built.
- // The keys 0 and 'countall' must always be present if tree is built.
- if ($id !== 0 && $id !== 'countall' && $coursecattreecache->has('countall')) {
- // Tree was built, it means the non-existing $id was requested.
- return false;
- }
// Re-build the tree.
$sql = "SELECT cc.id, cc.parent, cc.visible
FROM {course_categories} cc
if (array_key_exists($id, $all)) {
return $all[$id];
}
- return false;
+ // Requested non-existing category.
+ return array();
}
/**
$coursecatcache = cache::make('core', 'coursecat');
$cntcachekey = 'scnt-'. serialize($search);
if (($cnt = $coursecatcache->get($cntcachekey)) === false) {
- self::search_courses($search, $options);
- $cnt = $coursecatcache->get($cntcachekey);
+ // Cached value not found. Retrieve ALL courses and return their count.
+ unset($options['offset']);
+ unset($options['limit']);
+ unset($options['summary']);
+ unset($options['coursecontacts']);
+ $courses = self::search_courses($search, $options);
+ $cnt = count($courses);
}
return $cnt;
}
$cntcachekey = 'lcnt-'. $this->id. '-'. (!empty($options['recursive']) ? 'r' : '');
$coursecatcache = cache::make('core', 'coursecat');
if (($cnt = $coursecatcache->get($cntcachekey)) === false) {
- $this->get_courses($options);
- $cnt = $coursecatcache->get($cntcachekey);
+ // Cached value not found. Retrieve ALL courses and return their count.
+ unset($options['offset']);
+ unset($options['limit']);
+ unset($options['summary']);
+ unset($options['coursecontacts']);
+ $courses = $this->get_courses($options);
+ $cnt = count($courses);
}
return $cnt;
}