MDL-41042 coursecat: better handle changes in coursecontact

This commit is contained in:
Marina Glancy
2015-10-07 10:15:19 +08:00
parent 35d3e8b00b
commit a6d4a36388
3 changed files with 4 additions and 10 deletions
+1 -10
View File
@@ -708,16 +708,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
}
$managerroles = explode(',', $CFG->coursecontact);
$cache = cache::make('core', 'coursecontacts');
$cacheddata = $cache->get_many(array_merge(array('basic'), array_keys($courses)));
// Check if cache was set for the current course contacts and it is not yet expired.
if (empty($cacheddata['basic']) || $cacheddata['basic']['roles'] !== $CFG->coursecontact ||
$cacheddata['basic']['lastreset'] < time() - self::CACHE_COURSE_CONTACTS_TTL) {
// Reset cache.
$keys = $DB->get_fieldset_select('course', 'id', '');
$cache->delete_many($keys);
$cache->set('basic', array('roles' => $CFG->coursecontact, 'lastreset' => time()));
$cacheddata = $cache->get_many(array_merge(array('basic'), array_keys($courses)));
}
$cacheddata = $cache->get_many(array_keys($courses));
$courseids = array();
foreach (array_keys($courses) as $id) {
if ($cacheddata[$id] !== false) {